Commit d8f028cc authored by Felix Schlösser / TinTin's avatar Felix Schlösser / TinTin
Browse files

state before multi table inheritance for motions

parent 8c1b5b15
Pipeline #145281 failed with stages
in 13 seconds
......@@ -90,6 +90,8 @@ THIRD_PARTY_APPS = [
LOCAL_APPS = [
"meeting_transparency.motions",
"meeting_transparency.meetings",
"meeting_transparency.decisions",
"meeting_transparency.people",
# Your stuff: custom apps go here
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
......@@ -264,3 +266,4 @@ LOGGING = {
# Your stuff...
# ------------------------------------------------------------------------------
TAGGIT_CASE_INSENSITIVE = True
CURRENCIES = ('EUR',)
......@@ -10,6 +10,7 @@ SECRET_KEY = env(
"DJANGO_SECRET_KEY",
default="oDWs3jsOgte5pcoM3PAvFzzZZ64Eox6anOI9HJSk5vaQrwRrazns7OT81TQbEpAy",
)
HASHID_FIELD_SALT = "oPWs3jsOgte5pcoM3PAvFzzZZ64Eox6anOI9HkSk5vaQrwRrazns7OT81TQbEpAy"
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"]
......
from django.contrib import admin
from .models import *
# Register your models here.
@admin.register(AstaDecision)
class AstaDecisionAdmin(admin.ModelAdmin):
pass
@admin.register(BoardDecision)
class BoardDecisionAdmin(admin.ModelAdmin):
pass
@admin.register(ExtendedBoardDecision)
class ExtendenBoardDecisionAdmin(admin.ModelAdmin):
pass
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class DecisionsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'decisions'
name = "meeting_transparency.decisions"
verbose_name = _("Beschlüsse")
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.core.exceptions import ValidationError, ObjectDoesNotExist
from model_utils.models import TimeStampedModel
from model_utils.fields import StatusField
from hashid_field import HashidAutoField
from datetime import datetime, timedelta
# Create your models here.
class decision
class DecisionManager(models.Manager):
def create_decision(self, meeting, motion, has_passed, note=None):
if has_passed:
voting_result = AbstractDecision.VOTING_RESULT_CHOICES["ACCEPTED"]
else:
voting_result = AbstractDecision.VOTING_RESULT_CHOICES["REJECTED"]
decision = self.create(
underlying_motion=motion, voting_result=voting_result, note=note
)
return decision
class AbstractDecision(TimeStampedModel):
id = HashidAutoField(primary_key=True)
VOTING_RESULT_CHOICES = [
("ACCEPTED", _("angenommen")),
("REJECTED", _("abgelehnt")),
]
voting_result = StatusField(
choices_name="VOTING_RESULT_CHOICES", verbose_name=_("Anstimmungsergebnis")
)
note = models.TextField(
max_length=512, verbose_name=_("Bemerkung"), blank=True, null=True
)
objects = DecisionManager()
class Meta:
verbose_name = _("Beschluss")
verbose_name_plural = _("Beschlüsse")
ordering = ["created"]
abstract = True
def __str__(self):
return f"{ self.created.strftime('%x') }: { self.underlying_motion.title } "
@property
def motion(self):
return self.agenda_item.motion
@property
def meeting(self):
return self.agenda_item.meeting
def clean(self):
# Dont allow decisions to be changed retroactivly, but allow a time window to allow for corrections.
if datetime.now() > self.created + timedelta(hours=24):
if self.created != self.modified:
raise ValidationError(
f"24h nach Erstellung werden Beschlüssene vom System eingefrohren und können nicht mehr verändert werden. \
Wenn du glaubst, dass sich hierbei um einen Fehler handelt, wende dich an den Administrator.",
code="editing-forzen-motion",
)
class AstaDecision(AbstractDecision):
agenda_item = models.OneToOneField("meetings.AgendaItem", on_delete=models.PROTECT)
class Meta(AbstractDecision.Meta):
verbose_name = _("AStA-Beschluss")
verbose_name_plural = _("AStA-Beschlüsse")
class BoardDecision(AbstractDecision):
agenda_item = models.OneToOneField("meetings.BoardMeetingAgendaItem", on_delete=models.PROTECT)
class Meta(AbstractDecision.Meta):
verbose_name = _("Vorstandsbeschluss")
verbose_name_plural = _("Vorstandsbeschlüsse")
class ExtendedBoardDecision(AbstractDecision):
agenda_item = models.OneToOneField("meetings.ExtendedBoardMeetingAgendaItem", on_delete=models.PROTECT)
class Meta(BoardDecision.Meta):
verbose_name = _("erweiterter Vorstandsbeschluss")
verbose_name_plural = _("erweiterter Vorstandsbeschlüsse")
......@@ -3,8 +3,34 @@ from django.contrib import admin
from .models import *
# Register your models here.
@admin.register(Meeting)
class MeetingAdmin(admin.ModelAdmin):
@admin.register(AstaMeeting)
class AStAMeetingAdmin(admin.ModelAdmin):
pass
@admin.register(BoardMeeting)
class BoardMeetingAdmin(admin.ModelAdmin):
pass
@admin.register(ExtendedBoardMeeting)
class ExtendedBoardMeetingAdmin(admin.ModelAdmin):
pass
@admin.register(AgendaItem)
class AgendaItemAdmin(admin.ModelAdmin):
list_display = ('__str__', 'meeting')
@admin.register(BoardMeetingAgendaItem)
class BoardMeetingAgendaItemAdmin(admin.ModelAdmin):
list_display = ('__str__', 'meeting')
@admin.register(ExtendedBoardMeetingAgendaItem)
class ExtendedBoardMeetingAgendaItemAdmin(admin.ModelAdmin):
list_display = ('__str__', 'meeting')
@admin.register(LegislativePeriod)
class LegislativePeriodAdmin(admin.ModelAdmin):
pass
@admin.register(Room)
......@@ -12,13 +38,10 @@ class RoomAdmin(admin.ModelAdmin):
pass
@admin.register(Format)
class LocationAdmin(admin.ModelAdmin):
class FormatAdmin(admin.ModelAdmin):
pass
@admin.register(VideoConferenceRoom)
class VideoConferenceRoomAdmin(admin.ModelAdmin):
pass
@admin.register(LegislativePeriod)
class LegislativePeriodAdmin(admin.ModelAdmin):
pass
This diff is collapsed.
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class MembersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'members'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.contrib import admin
# Register your models here.
from .models import *
# Register your models here.
@admin.register(Person)
class PersonAdmin(admin.ModelAdmin):
pass
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class PeopleConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'people'
name = "meeting_transparency.people"
verbose_name = _("Personen")
from django.db import models
from django.utils.translation import gettext_lazy as _
# Create your models here.
class Person(models.Model):
name = models.CharField(max_length=256)
is_asta_member = models.BooleanField()
is_asta_board_member = models.BooleanField()
class Meta:
ordering = ['is_asta_board_member', 'is_asta_member']
verbose_name = _("Person")
verbose_name_plural = _("Personen")
def __str__(self):
return self.name
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class RoomsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'rooms'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment