Commit e9b4c45a authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Merge branch 'fix/misc-documents-fixes' into 'master'

Miscellaneous documents fixes

Closes #612

See merge request !765
parents bc834330 95fc4a10
......@@ -9,7 +9,7 @@ from utils.translation import TranslatedModelAdmin
class MinutesInline(admin.StackedInline):
model = Minutes
fields = ('file_nl', 'file_en')
fields = ('file_nl', 'file_en', 'members_only',)
class GeneralMeetingForm(forms.ModelForm):
......@@ -33,7 +33,7 @@ class GeneralMeetingAdmin(TranslatedModelAdmin):
@admin.register(AnnualDocument)
class AnnualDocument(TranslatedModelAdmin):
fields = ('file', 'subcategory', 'year',)
fields = ('file', 'subcategory', 'year', 'members_only',)
list_filter = ('year', 'created', 'last_updated',)
......
......@@ -60,6 +60,12 @@ class Migration(migrations.Migration):
bases=('documents.document',),
),
migrations.RenameField(
model_name='GeneralMeeting',
old_name='minutes',
new_name='minutes_old',
),
migrations.CreateModel(
name='Minutes',
fields=[
......@@ -76,7 +82,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='GeneralMeeting',
name='documents',
field=models.ManyToManyField(to='documents.Document'),
field=models.ManyToManyField(to='documents.Document', verbose_name='documents', blank=True),
),
migrations.AlterField(
......@@ -100,7 +106,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='GeneralMeeting',
name='location_en',
field=models.CharField(max_length=200, verbose_name='location (EN)'),
field=models.CharField(max_length=200, verbose_name='location (EN)', blank=True, null=True),
),
migrations.AlterModelOptions(
......
......@@ -17,7 +17,8 @@ def make_assocation_documents(apps, schema_editor):
name_nl = doc.name,
file_en = doc.file,
file_nl = doc.file,
members_only = doc.members_only
members_only = doc.members_only,
category = 'association',
)
......@@ -33,6 +34,7 @@ def make_annual_documents(apps, schema_editor):
file_en = year.policy_document,
file_nl = year.policy_document,
members_only = True,
category = 'annual',
subcategory = 'policy',
year = year.year,
)
......@@ -44,6 +46,7 @@ def make_annual_documents(apps, schema_editor):
file_en = year.annual_report,
file_nl = year.annual_report,
members_only = True,
category = 'annual',
subcategory = 'report',
year = year.year,
)
......@@ -54,6 +57,7 @@ def make_annual_documents(apps, schema_editor):
name_nl = 'Financieel jaarverslag %d' % year.year,
file = year.financial_report,
members_only = True,
category = 'annual',
subcategory = 'financial',
year = year.year,
)
......@@ -64,7 +68,7 @@ def make_general_meeting_documents(apps, schema_editor):
GeneralMeetingDocument = apps.get_model('documents', 'GeneralMeetingDocument')
for meeting_doc in GeneralMeetingDocument.objects.all():
name = os.path.basename(meeting_doc.name),
name = os.path.basename(meeting_doc.file.name),
doc = Document.objects.create(
name_en = name,
name_nl = name,
......@@ -81,15 +85,24 @@ def make_minutes_documents(apps, schema_editor):
Minutes = apps.get_model('documents', 'Minutes')
for meeting in GeneralMeeting.objects.all():
Minutes.objects.create(
name_en = 'Minutes %s' % str(meeting.datetime.date()),
name_nl = 'Notulen %s' % str(meeting.datetime.date()),
category = 'minutes',
file_en = meeting.minutes,
file_nl = meeting.minutes,
members_only = True,
meeting = meeting,
)
if meeting.minutes_old:
Minutes.objects.create(
name_en = 'Minutes %s' % str(meeting.datetime.date()),
name_nl = 'Notulen %s' % str(meeting.datetime.date()),
category = 'minutes',
file_en = meeting.minutes_old,
file_nl = meeting.minutes_old,
members_only = True,
meeting = meeting,
)
def set_location_en_meetings(apps, schema_editor):
GeneralMeeting = apps.get_model('documents', 'GeneralMeeting')
for meeting in GeneralMeeting.objects.all():
meeting.location_en = meeting.location_nl
meeting.save()
class Migration(migrations.Migration):
......@@ -111,4 +124,7 @@ class Migration(migrations.Migration):
migrations.RunPython(
make_minutes_documents
),
migrations.RunPython(
set_location_en_meetings
),
]
......@@ -15,7 +15,13 @@ class Migration(migrations.Migration):
operations = [
migrations.RemoveField(
model_name='GeneralMeeting',
name='minutes',
name='minutes_old',
),
migrations.AlterField(
model_name='GeneralMeeting',
name='location_en',
field=models.CharField(max_length=200, verbose_name='location (EN)'),
),
migrations.DeleteModel(
......
......@@ -140,6 +140,8 @@ class GeneralMeeting(models.Model, metaclass=ModelTranslateMeta):
documents = models.ManyToManyField(
Document,
verbose_name=_('documents'),
blank=True,
)
datetime = models.DateTimeField(
......
Supports Markdown
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