Skip to content

Commit

Permalink
delete a4 tables, organisation models and reset home migrations.
Browse files Browse the repository at this point in the history
run 'python manage.py migrate --fake home zero' and 'python manage.py migrate --fake-initial' to fix the migration state
  • Loading branch information
goapunk committed Sep 12, 2024
1 parent 91b8f7c commit 273f7f2
Show file tree
Hide file tree
Showing 54 changed files with 387 additions and 3,608 deletions.
15 changes: 0 additions & 15 deletions euth/contrib/admin.py

This file was deleted.

37 changes: 37 additions & 0 deletions euth/contrib/migrations/0001_delete_a4_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 3.2.20 on 2024-09-10 15:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
]

operations = [
migrations.RunSQL(
sql=[
"DROP TABLE IF EXISTS background_task",
"DROP TABLE IF EXISTS background_task_completedtask",
"DROP TABLE IF EXISTS a4categories_category",
"DROP TABLE IF EXISTS a4comments_comment",
"DROP TABLE IF EXISTS a4maps_areasettings",
"DROP TABLE IF EXISTS a4phases_phase",
"DROP TABLE IF EXISTS a4polls_answer",
"DROP TABLE IF EXISTS a4polls_othervote",
"DROP TABLE IF EXISTS a4polls_vote",
"DROP TABLE IF EXISTS a4polls_choice",
"DROP TABLE IF EXISTS a4polls_question",
"DROP TABLE IF EXISTS a4polls_poll",
"DROP TABLE IF EXISTS a4modules_item",
"DROP TABLE IF EXISTS a4modules_module",
"DROP TABLE IF EXISTS a4projects_project_moderators",
"DROP TABLE IF EXISTS a4projects_project_participants",
"DROP TABLE IF EXISTS a4projects_project",
"DROP TABLE IF EXISTS a4ratings_rating",
"DROP TABLE IF EXISTS a4reports_report",
"DROP TABLE IF EXISTS a4administrative_districts_administrativedistrict",
],
reverse_sql=migrations.RunSQL.noop,
)
]
Empty file.
12 changes: 0 additions & 12 deletions euth/contrib/sitemaps/adhocracy4_sitemap.py

This file was deleted.

27 changes: 27 additions & 0 deletions euth/organisations/migrations/0007_auto_20240910_1638.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.2.20 on 2024-09-10 14:38

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('euth_organisations', '0006_update_parler_field'),
]

operations = [
migrations.AlterUniqueTogether(
name='organisationtranslation',
unique_together=None,
),
migrations.RemoveField(
model_name='organisationtranslation',
name='master',
),
migrations.DeleteModel(
name='Organisation',
),
migrations.DeleteModel(
name='OrganisationTranslation',
),
]
73 changes: 0 additions & 73 deletions euth/organisations/models.py
Original file line number Diff line number Diff line change
@@ -1,73 +0,0 @@
from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _
from django_countries import fields as countries_fields
from parler.models import TranslatableManager
from parler.models import TranslatableModel
from parler.models import TranslatedFields

from adhocracy4.images import fields
from adhocracy4.models import base


class OrganisationManager(TranslatableManager):
def get_by_natural_key(self, name):
return self.get(name=name)


class Organisation(base.TimeStampedModel, TranslatableModel):
name = models.CharField(
max_length=512,
unique=True,
verbose_name=_('title')
)
slug = models.SlugField(max_length=512, unique=True)

translations = TranslatedFields(
description_why=models.TextField(),
description_how=models.TextField(),
description=models.TextField(),
)

initiators = models.ManyToManyField(settings.AUTH_USER_MODEL)
image = fields.ConfiguredImageField(
'heroimage',
upload_to='organisations/images',
blank=True,
verbose_name=_('Header image'),
help_prefix=_(
'The image sets the atmosphere for your organisation page.'
),
)
logo = fields.ConfiguredImageField(
'logo',
upload_to='organisations/logos',
blank=True,
help_prefix=_(
'The official logo of your organisation.'
),
)
twitter_handle = models.CharField(max_length=200, blank=True)
facebook_handle = models.CharField(max_length=200, blank=True)
instagram_handle = models.CharField(max_length=200, blank=True)
webpage = models.URLField(blank=True)
country = countries_fields.CountryField()
place = models.CharField(max_length=200)

objects = OrganisationManager()

def __str__(self):
return self.name

def has_social_share(self):
return (
self.twitter_handle or self.facebook_handle
or self.instagram_handle or self.webpage
)

def has_initiator(self, user):
return user in self.initiators.all()

def get_absolute_url(self):
from django.urls import reverse
return reverse('organisation-detail', args=[str(self.slug)])
25 changes: 0 additions & 25 deletions euth_wagtail/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,6 @@
'allauth.socialaccount',
'micawber.contrib.mcdjango',

'adhocracy4.administrative_districts',
'adhocracy4.images',
'adhocracy4.forms',
'adhocracy4.phases',
'adhocracy4.projects',
'adhocracy4.ratings',
'adhocracy4.reports',
'adhocracy4.modules',
'adhocracy4.categories',
'adhocracy4.comments',
'adhocracy4.comments_async',
'adhocracy4.maps',
'adhocracy4.filters',
'adhocracy4.rules',
'adhocracy4.ckeditor',
'adhocracy4.dashboard',
'adhocracy4.polls',
'adhocracy4.organisations',
'euth.users',
'euth.organisations',
'euth.accounts',
Expand Down Expand Up @@ -414,13 +396,6 @@
)

A4_COMMENTABLES = (
('euth_communitydebate', 'topic'),
('euth_ideas', 'idea'),
('euth_maps', 'mapidea'),
('euth_documents', 'paragraph'),
('euth_documents', 'document'),
('a4comments', 'comment'),
('a4polls', 'poll')
)

A4_COMMENT_CATEGORIES = (
Expand Down
21 changes: 0 additions & 21 deletions euth_wagtail/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,19 @@
from django.views.decorators.cache import never_cache
from django.views.generic import TemplateView
from django.views.i18n import JavaScriptCatalog
from rest_framework import routers
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.contrib.sitemaps import views as wagtail_sitemap_views
from wagtail.contrib.sitemaps.sitemap_generator import \
Sitemap as WagtailSitemap
from wagtail.documents import urls as wagtaildocs_urls

from adhocracy4.api import routers as a4routers
from adhocracy4.comments_async.api import CommentViewSet
from adhocracy4.polls.api import PollViewSet
from adhocracy4.ratings.api import RatingViewSet
from adhocracy4.reports.api import ReportViewSet
from euth.accounts import urls as accounts_urls
from euth.contrib.sitemaps.adhocracy4_sitemap import Adhocracy4Sitemap
from euth.contrib.sitemaps.static_sitemap import StaticSitemap

from . import urls_accounts

router = routers.DefaultRouter()
router.register(r'polls', PollViewSet, basename='polls')
router.register(r'reports', ReportViewSet, basename='reports')

ct_router = a4routers.ContentTypeDefaultRouter()
ct_router.register(r'comments', CommentViewSet, basename='comments')
ct_router.register(r'ratings', RatingViewSet, basename='ratings')

module_router = a4routers.ModuleDefaultRouter()

sitemaps = {
'adhocracy4': Adhocracy4Sitemap,
'wagtail': WagtailSitemap,
'static': StaticSitemap
}
Expand All @@ -48,9 +30,6 @@
path('django-admin/', admin.site.urls),
path('admin/', include(wagtailadmin_urls)),
path('documents/', include(wagtaildocs_urls)),
path('api/', include(router.urls)),
path('api/', include(ct_router.urls)),
path('api/', include(module_router.urls)),
path('upload/', login_required(ck_views.upload), name='ckeditor_upload'),
path('browse/',
never_cache(login_required(ck_views.browse)), name='ckeditor_browse'),
Expand Down
Loading

0 comments on commit 273f7f2

Please sign in to comment.