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