Skip to content

Commit

Permalink
Formats all files with black
Browse files Browse the repository at this point in the history
  • Loading branch information
mrharpo committed Nov 2, 2023
1 parent 57a87ae commit ddbe716
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 28 deletions.
19 changes: 15 additions & 4 deletions exhibits/management/commands/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ def handle(self, old_name, new_name, models, *args, **options):
# Rename model
old_name = old_name[0]
new_name = new_name[0]
cursor.execute("UPDATE django_content_type SET app_label='{}' WHERE app_label='{}'".format(new_name, old_name))
cursor.execute("UPDATE django_migrations SET app='{}' WHERE app='{}'".format(new_name, old_name))
cursor.execute(
"UPDATE django_content_type SET app_label='{}' WHERE app_label='{}'".format(
new_name, old_name
)
)
cursor.execute(
"UPDATE django_migrations SET app='{}' WHERE app='{}'".format(
new_name, old_name
)
)

for model in models:
cursor.execute("ALTER TABLE {old_name}_{model_name} RENAME TO {new_name}_{model_name}".format(
old_name=old_name, new_name=new_name, model_name=model))
cursor.execute(
"ALTER TABLE {old_name}_{model_name} RENAME TO {new_name}_{model_name}".format(
old_name=old_name, new_name=new_name, model_name=model
)
)
19 changes: 11 additions & 8 deletions exhibits/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,20 @@ class ExhibitPage(Page):
]

content_panels = Page.content_panels + [
MultiFieldPanel([
FieldPanel('cover_image'),
FieldPanel('hero_image'),
], heading='Images'),
MultiFieldPanel(
[
FieldPanel('cover_image'),
FieldPanel('hero_image'),
],
heading='Images',
),
FieldPanel('body', classname='collapsed'),
InlinePanel('authors', heading='Author(s)'),
InlinePanel(
'other_exhibits',
heading='Other Exhibits',
max_num=3,
)
'other_exhibits',
heading='Other Exhibits',
max_num=3,
),
]

api_fields = [
Expand Down
1 change: 0 additions & 1 deletion exhibits/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class ExhibitPageFactory(PageFactory):

cover_image = SubFactory(ImageChooserBlockFactory)
hero_image = SubFactory(ImageChooserBlockFactory)
# other_exhibits =
Expand Down
1 change: 1 addition & 0 deletions exhibits/tests/test_exhibit_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from ..models import ExhibitPage
from .factories import ExhibitPageFactory


# Create your tests here.
class ExhibitPageTests(TestCase):
def test_exhibit_page_factory(self):
Expand Down
5 changes: 2 additions & 3 deletions home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.api import APIField


class HomePage(Page):
body = RichTextField(blank=True)

content_panels = Page.content_panels + [
FieldPanel('body', classname="full"),
]

api_fields = [
APIField('body')
]
api_fields = [APIField('body')]
2 changes: 0 additions & 2 deletions ov_wag/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'




try:
from .local import *
except ImportError:
Expand Down
4 changes: 3 additions & 1 deletion ov_wag/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def test_exhibit_api_schema_single(self):
Compare response against ExhibitSchema
"""
exhibit_page = ExhibitPageFactory.create(parent=self.__home_page())
response = self.client.get(f'/api/v2/exhibits/{exhibit_page.id}/', format='json')
response = self.client.get(
f'/api/v2/exhibits/{exhibit_page.id}/', format='json'
)
json = response.json()
self.assertValidSchema(json)

Expand Down
4 changes: 0 additions & 4 deletions ov_wag/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@

urlpatterns = [
path('django-admin/', admin.site.urls),

path('admin/', include(wagtailadmin_urls)),
path('documents/', include(wagtaildocs_urls)),

path('search/', search_views.search, name='search'),
path('api/v2/', api_router.urls),

]


Expand All @@ -35,7 +32,6 @@
# Wagtail's page serving mechanism. This should be the last pattern in
# the list:
path("", include(wagtail_urls)),

# Alternatively, if you want Wagtail pages to be served from a subpath
# of your site, rather than the site root:
# path("pages/", include(wagtail_urls)),
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
# PEP 621 project metadata
# See https://www.python.org/dev/peps/pep-0621/
dependencies = ["Django<4.2,>=4.1.1", "wagtail<4.1,>=4.0.4", "wagtail-factories<3.2,>=3.1.0", "pydantic<2.0,>=1.10.2", "psycopg2<2.10,>=2.9.3"]
requires-python = ">=3.11"
requires-python = ">=3.8"


[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.black]
extend-exclude = 'migrations'
12 changes: 8 additions & 4 deletions search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def search(request):
except EmptyPage:
search_results = paginator.page(paginator.num_pages)

return TemplateResponse(request, 'search/search.html', {
'search_query': search_query,
'search_results': search_results,
})
return TemplateResponse(
request,
'search/search.html',
{
'search_query': search_query,
'search_results': search_results,
},
)

0 comments on commit ddbe716

Please sign in to comment.