Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👓 exhibit -> exhibits #68

Merged
merged 5 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions authors/migrations/0002_authorsorderable.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Migration(migrations.Migration):

dependencies = [
('exhibit', '0002_exhibitpage_cover_image'),
('exhibits', '0002_exhibitpage_cover_image'),
('authors', '0001_initial'),
]

Expand All @@ -19,7 +19,7 @@ class Migration(migrations.Migration):
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='authors.author')),
('page', modelcluster.fields.ParentalKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='authors', to='exhibit.exhibitpage')),
('page', modelcluster.fields.ParentalKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='authors', to='exhibits.exhibitpage')),
],
options={
'ordering': ['sort_order'],
Expand Down
2 changes: 1 addition & 1 deletion authors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class AuthorsOrderable(Orderable):
page = ParentalKey('exhibit.ExhibitPage', related_name='authors', null=True)
page = ParentalKey('exhibits.ExhibitPage', related_name='authors', null=True)
author = models.ForeignKey(
'authors.Author',
blank=True,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions exhibit/apps.py → exhibits/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import AppConfig


class ExhibitConfig(AppConfig):
class ExhibitsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'exhibit'
name = 'exhibits'
29 changes: 29 additions & 0 deletions exhibits/management/commands/rename.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Rename module
Shamelessly copied from https://gist.github.com/rafaponieman/201054ddf725cda1e60be3fe845850a5
"""
import argparse

from django.core.management.base import BaseCommand
from django.db import connection


class Command(BaseCommand):
help = 'Renames app. Usage rename_app [old_name] [new_name] [classes ...]'

def add_arguments(self, parser):
# Positional arguments
parser.add_argument('old_name', nargs=1, type=str)
parser.add_argument('new_name', nargs=1, type=str)
parser.add_argument('models', nargs=argparse.REMAINDER, type=str)

def handle(self, old_name, new_name, models, *args, **options):
with connection.cursor() as cursor:
# 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))

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))
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Migration(migrations.Migration):

dependencies = [
('wagtailimages', '0023_add_choose_permissions'),
('exhibit', '0001_initial'),
('exhibits', '0001_initial'),
]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Migration(migrations.Migration):

dependencies = [
('wagtailimages', '0023_add_choose_permissions'),
('exhibit', '0002_exhibitpage_cover_image'),
('exhibits', '0002_exhibitpage_cover_image'),
]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Migration(migrations.Migration):

dependencies = [
('exhibit', '0003_exhibitpage_hero_image'),
('exhibits', '0003_exhibitpage_hero_image'),
]

operations = [
Expand All @@ -17,8 +17,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('exhibit', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='exhibit.exhibitpage')),
('page', modelcluster.fields.ParentalKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='other_exhibits', to='exhibit.exhibitpage')),
('exhibit', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='exhibits.exhibitpage')),
('page', modelcluster.fields.ParentalKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='other_exhibits', to='exhibits.exhibitpage')),
],
options={
'ordering': ['sort_order'],
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions exhibit/models.py → exhibits/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@


class ExhibitsOrderable(Orderable):
page = ParentalKey('exhibit.ExhibitPage', related_name='other_exhibits', null=True)
page = ParentalKey('exhibits.ExhibitPage', related_name='other_exhibits', null=True)
exhibit = models.ForeignKey(
'exhibit.ExhibitPage',
'exhibits.ExhibitPage',
blank=True,
null=True,
on_delete=models.CASCADE,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion exhibit/tests/factories.py → exhibits/tests/factories.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from factory import SubFactory
from wagtail_factories import ImageChooserBlockFactory, PageFactory
from exhibit.models import ExhibitPage
from exhibits.models import ExhibitPage


class ExhibitPageFactory(PageFactory):
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions ov_wag/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from wagtail.images.api.v2.views import ImagesAPIViewSet
from wagtail.documents.api.v2.views import DocumentsAPIViewSet
from authors.api import AuthorsAPIViewSet
from exhibit.api import ExhibitAPIViewSet
from exhibits.api import ExhibitAPIViewSet

# Create the router. "wagtailapi" is the URL namespace
api_router = WagtailAPIRouter('wagtailapi')
Expand All @@ -16,4 +16,4 @@
api_router.register_endpoint('images', ImagesAPIViewSet)
api_router.register_endpoint('documents', DocumentsAPIViewSet)
api_router.register_endpoint('authors', AuthorsAPIViewSet)
api_router.register_endpoint('exhibit', ExhibitAPIViewSet)
api_router.register_endpoint('exhibits', ExhibitAPIViewSet)
2 changes: 1 addition & 1 deletion ov_wag/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
INSTALLED_APPS = [
'home',
'search',
'exhibit',
'exhibits',
'authors',
'wagtail.contrib.forms',
'wagtail.contrib.modeladmin',
Expand Down
8 changes: 4 additions & 4 deletions ov_wag/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from rest_framework.test import APITestCase
from wagtail.core.models import Site
import wagtail_factories
from exhibit.models import ExhibitPageApiSchema
from exhibit.tests.factories import ExhibitPageFactory
from exhibits.models import ExhibitPageApiSchema
from exhibits.tests.factories import ExhibitPageFactory


class ApiTests(APITestCase):
Expand Down Expand Up @@ -41,7 +41,7 @@ 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/exhibit/{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 All @@ -52,7 +52,7 @@ def test_exhibit_api_schema_multiple(self):
Compare response against ExhibitSchema
"""
exhibit_page = ExhibitPageFactory.create(parent=self.__home_page())
response = self.client.get(f'/api/v2/exhibit/', format='json')
response = self.client.get(f'/api/v2/exhibits/', format='json')
json = response.json()
for item in json['items']:
self.assertValidSchema(item)
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ DJANGO_SETTINGS_MODULE = ov_wag.settings.dev
python_files = tests.py test_*.py *_tests.py
testpaths =
authors
exhibit
exhibits
ov_wag