Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
2c50be56
Commit
2c50be56
authored
Feb 08, 2018
by
Tom van Bussel
Browse files
Refactored documents app
parent
8fd3b1d2
Changes
20
Hide whitespace changes
Inline
Side-by-side
website/documents/admin.py
View file @
2c50be56
from
django
import
forms
from
django.contrib
import
admin
from
documents.models
import
(
AssociationDocumentsYear
,
GeneralMeeting
,
GeneralMeetingDocument
,
MiscellaneousDocument
)
from
documents.models
import
(
AnnualDocument
,
AssociationDocument
,
GeneralMeeting
,
Minutes
,
MiscellaneousDocument
)
from
utils.translation
import
TranslatedModelAdmin
class
GeneralMeetingDocInline
(
admin
.
StackedInline
):
model
=
GeneralMeetingDocument
classes
=
(
'collapse'
,)
class
MinutesInline
(
admin
.
StackedInline
):
model
=
Minutes
fields
=
(
'file'
,)
class
GeneralMeetingForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
GeneralMeeting
exclude
=
()
widgets
=
{
'documents'
:
admin
.
widgets
.
FilteredSelectMultiple
(
'documents'
,
is_stacked
=
False
)
}
@
admin
.
register
(
GeneralMeeting
)
class
GeneralMeetingAdmin
(
admin
.
ModelAdmin
):
inlines
=
(
GeneralMeetingDocInline
,
)
class
GeneralMeetingAdmin
(
TranslatedModelAdmin
):
form
=
GeneralMeetingForm
inlines
=
[
MinutesInline
,
]
list_filter
=
(
'datetime'
,)
@
admin
.
register
(
AnnualDocument
)
class
AnnualDocument
(
TranslatedModelAdmin
):
fields
=
(
'file'
,
'subcategory'
,
'year'
,)
list_filter
=
(
'year'
,
'created'
,
'last_updated'
,)
@
admin
.
register
(
AssociationDocument
)
class
AssociationDocumentAdmin
(
TranslatedModelAdmin
):
fields
=
(
'name'
,
'file'
,
'members_only'
,)
list_filter
=
(
'created'
,
'last_updated'
,)
admin
.
site
.
register
(
MiscellaneousDocument
)
admin
.
site
.
register
(
AssociationDocumentsYear
)
@
admin
.
register
(
MiscellaneousDocument
)
class
MiscellaneousDocumentAdmin
(
TranslatedModelAdmin
):
fields
=
(
'name'
,
'file'
,
'members_only'
,)
list_filter
=
(
'created'
,
'last_updated'
,)
website/documents/locale/nl/LC_MESSAGES/django.mo
View file @
2c50be56
No preview for this file type
website/documents/locale/nl/LC_MESSAGES/django.po
View file @
2c50be56
...
...
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-12 1
4:06
+0100\n"
"PO-Revision-Date: 2018-02-12 1
3:42
+0100\n"
"POT-Creation-Date: 2018-02-12 1
6:18
+0100\n"
"PO-Revision-Date: 2018-02-12 1
6:21
+0100\n"
"Last-Translator: Joost Rijneveld <joost@joostrijneveld.nl>\n"
"Language-Team: \n"
"Language: nl\n"
...
...
@@ -16,15 +16,108 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.0.
6
\n"
"X-Generator: Poedit 2.0.
4
\n"
#: apps.py:7 templates/documents/index.html:6 templates/documents/index.html:7
#: apps.py:7 models.py:13 templates/documents/index.html:6
#: templates/documents/index.html:7
msgid "Documents"
msgstr "Documenten"
#: models.py:12
msgid "Document"
msgstr "Document"
#: models.py:16 models.py:63
msgid "Annual document"
msgstr "Jaarlijks document"
#: models.py:17
msgid "Association document"
msgstr "Verenigingsdocument"
#: models.py:18 models.py:161 models.py:162
msgid "Minutes"
msgstr "Notulen"
#: models.py:19 models.py:124
msgid "Miscellaneous document"
msgstr "Overig document"
#: models.py:24
msgid "name"
msgstr "naam"
#: models.py:29
msgid "created"
msgstr "aangemaakt op"
#: models.py:34
msgid "last updated"
msgstr "laatst aangemaakt op"
#: models.py:41 models.py:76
msgid "category"
msgstr "categorie"
#: models.py:47
msgid "file"
msgstr "bestand"
#: models.py:53
msgid "members only"
msgstr "alleen voor leden"
#: models.py:64
msgid "Annual documents"
msgstr "Jaarlijkse documenten"
#: models.py:68 templates/documents/index.html:46
msgid "Annual report"
msgstr "Jaarverslag"
#: models.py:69
msgid "Financial report"
msgstr "Financieel jaarverslag"
#: models.py:70
msgid "Policy document"
msgstr "Beleidsdocument"
#: models.py:81
msgid "year"
msgstr "jaar"
#: models.py:106
msgid "Miscellaneous association document"
msgstr "Overig verenigingsdocument"
#: models.py:107
msgid "Miscellaneous association documents"
msgstr "Overige verenigingsdocumenten"
#: models.py:125
msgid "Miscellaneous documents"
msgstr "Overig documenten"
#: models.py:137
msgid "General meeting"
msgstr "Algemene ledenvergadering"
#: models.py:138
msgid "General meetings"
msgstr "Algemene ledenvergaderingen"
#: models.py:146
msgid "datetime"
msgstr "tijdstip"
#: models.py:151
msgid "location"
msgstr "locatie"
#: templates/documents/index.html:17
msgid "Miscellaneous Documents"
msgstr "
Algeme
en"
msgid "Miscellaneous
Association
Documents"
msgstr "
Overige Verenigingsdocument
en"
#: templates/documents/index.html:19
msgid ""
...
...
@@ -72,10 +165,6 @@ msgstr ""
msgid "Policy"
msgstr "Beleidsdocument"
#: templates/documents/index.html:46
msgid "Annual report"
msgstr "Jaarverslag"
#: templates/documents/index.html:55
msgid "General Meetings"
msgstr "Algemene Ledenvergaderingen"
...
...
website/documents/migrations/0005_auto_20160813_1116.py
View file @
2c50be56
...
...
@@ -3,9 +3,12 @@
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
documents.models
import
utils.validators
def
meetingdocument_upload_to
(
instance
,
filename
):
return
'documents/meetings/{}/files/{}'
.
format
(
instance
.
meeting
.
pk
,
filename
)
class
Migration
(
migrations
.
Migration
):
...
...
@@ -17,6 +20,6 @@ class Migration(migrations.Migration):
migrations
.
AlterField
(
model_name
=
'generalmeetingdocument'
,
name
=
'file'
,
field
=
models
.
FileField
(
upload_to
=
documents
.
models
.
meetingdocument_upload_to
,
validators
=
[
utils
.
validators
.
validate_file_extension
]),
field
=
models
.
FileField
(
upload_to
=
meetingdocument_upload_to
,
validators
=
[
utils
.
validators
.
validate_file_extension
]),
),
]
website/documents/migrations/0008_0_refactor_documents.py
0 → 100644
View file @
2c50be56
from
__future__
import
unicode_literals
import
django.core.validators
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
utils.validators
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'documents'
,
'0007_auto_20160930_1447'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Document'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name_nl'
,
models
.
CharField
(
max_length
=
200
,
verbose_name
=
'name (NL)'
)),
(
'name_en'
,
models
.
CharField
(
max_length
=
200
,
verbose_name
=
'name (EN)'
)),
(
'created'
,
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
'created'
)),
(
'last_updated'
,
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
'last updated'
)),
(
'category'
,
models
.
CharField
(
choices
=
[(
'annual'
,
'Annual document'
),
(
'association'
,
'Association document'
),
(
'minutes'
,
'Minutes'
),
(
'misc'
,
'Miscellaneous document'
)],
default
=
'misc'
,
max_length
=
40
,
verbose_name
=
'category'
)),
(
'file_en'
,
models
.
FileField
(
upload_to
=
'documents/'
,
validators
=
[
utils
.
validators
.
validate_file_extension
],
verbose_name
=
'file (EN)'
)),
(
'file_nl'
,
models
.
FileField
(
upload_to
=
'documents/'
,
validators
=
[
utils
.
validators
.
validate_file_extension
],
verbose_name
=
'file (NL)'
)),
(
'members_only'
,
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'members only'
)),
],
options
=
{
'verbose_name'
:
'Document'
,
'verbose_name_plural'
:
'Documents'
},
),
migrations
.
CreateModel
(
name
=
'AnnualDocument'
,
fields
=
[
(
'document_ptr'
,
models
.
OneToOneField
(
auto_created
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
parent_link
=
True
,
primary_key
=
True
,
serialize
=
False
,
to
=
'documents.Document'
)),
(
'subcategory'
,
models
.
CharField
(
choices
=
[(
'report'
,
'Annual report'
),
(
'financial'
,
'Financial report'
),
(
'policy'
,
'Policy document'
)],
default
=
'report'
,
max_length
=
40
,
verbose_name
=
'category'
)),
(
'year'
,
models
.
IntegerField
(
validators
=
[
django
.
core
.
validators
.
MinValueValidator
(
1990
)],
verbose_name
=
'year'
)),
],
options
=
{
'unique_together'
:
{(
'subcategory'
,
'year'
)},
'verbose_name'
:
'Annual document'
,
'verbose_name_plural'
:
'Annual documents'
,
},
bases
=
(
'documents.document'
,),
),
migrations
.
CreateModel
(
name
=
'AssociationDocument'
,
fields
=
[
],
options
=
{
'verbose_name'
:
'Miscellaneous association document'
,
'verbose_name_plural'
:
'Miscellaneous association documents'
,
'proxy'
:
True
,
'indexes'
:
[],
},
bases
=
(
'documents.document'
,),
),
migrations
.
CreateModel
(
name
=
'Minutes'
,
fields
=
[
(
'document_ptr'
,
models
.
OneToOneField
(
auto_created
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
parent_link
=
True
,
primary_key
=
True
,
serialize
=
False
,
to
=
'documents.Document'
)),
(
'meeting'
,
models
.
OneToOneField
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'documents.GeneralMeeting'
)),
],
options
=
{
'verbose_name'
:
'Minutes'
,
'verbose_name_plural'
:
'Minutes'
,
},
bases
=
(
'documents.document'
,),
),
migrations
.
AddField
(
model_name
=
'GeneralMeeting'
,
name
=
'documents'
,
field
=
models
.
ManyToManyField
(
to
=
'documents.Document'
),
),
migrations
.
AlterField
(
model_name
=
'GeneralMeeting'
,
name
=
'datetime'
,
field
=
models
.
DateTimeField
(
verbose_name
=
'datetime'
),
),
migrations
.
RenameField
(
model_name
=
'GeneralMeeting'
,
old_name
=
'location'
,
new_name
=
'location_nl'
,
),
migrations
.
AlterField
(
model_name
=
'GeneralMeeting'
,
name
=
'location_nl'
,
field
=
models
.
CharField
(
max_length
=
200
,
verbose_name
=
'location (NL)'
),
),
migrations
.
AddField
(
model_name
=
'GeneralMeeting'
,
name
=
'location_en'
,
field
=
models
.
CharField
(
max_length
=
200
,
verbose_name
=
'location (EN)'
),
),
migrations
.
AlterModelOptions
(
name
=
'generalmeeting'
,
options
=
{
'ordering'
:
[
'datetime'
],
'verbose_name'
:
'General meeting'
,
'verbose_name_plural'
:
'General meetings'
},
),
]
website/documents/migrations/0008_1_refactor_documents.py
0 → 100644
View file @
2c50be56
from
__future__
import
unicode_literals
import
os
import
django.core.validators
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
utils.validators
def
make_assocation_documents
(
apps
,
schema_editor
):
MiscellaneousDocument
=
apps
.
get_model
(
'documents'
,
'MiscellaneousDocument'
)
AssociationDocument
=
apps
.
get_model
(
'documents'
,
'AssociationDocument'
)
for
doc
in
MiscellaneousDocument
.
objects
.
all
():
AssociationDocument
.
objects
.
create
(
name_en
=
doc
.
name
,
name_nl
=
doc
.
name
,
file_en
=
doc
.
file
,
file_nl
=
doc
.
file
,
members_only
=
doc
.
members_only
)
def
make_annual_documents
(
apps
,
schema_editor
):
AssociationDocumentsYear
=
apps
.
get_model
(
'documents'
,
'AssociationDocumentsYear'
)
AnnualDocument
=
apps
.
get_model
(
'documents'
,
'AnnualDocument'
)
for
year
in
AssociationDocumentsYear
.
objects
.
all
():
if
year
.
policy_document
:
AnnualDocument
.
objects
.
create
(
name_en
=
'Policy document %d'
%
year
.
year
,
name_nl
=
'Beleidsdocument %d'
%
year
.
year
,
file_en
=
year
.
policy_document
,
file_nl
=
year
.
policy_document
,
members_only
=
True
,
subcategory
=
'policy'
,
year
=
year
.
year
,
)
if
year
.
annual_report
:
AnnualDocument
.
objects
.
create
(
name_en
=
'Annual report %d'
%
year
.
year
,
name_nl
=
'Jaarverslag %d'
%
year
.
year
,
file_en
=
year
.
annual_report
,
file_nl
=
year
.
annual_report
,
members_only
=
True
,
subcategory
=
'report'
,
year
=
year
.
year
,
)
if
year
.
financial_report
:
AnnualDocument
.
objects
.
create
(
name_en
=
'Financial report %d'
%
year
.
year
,
name_nl
=
'Financieel jaarverslag %d'
%
year
.
year
,
file
=
year
.
financial_report
,
members_only
=
True
,
subcategory
=
'financial'
,
year
=
year
.
year
,
)
def
make_general_meeting_documents
(
apps
,
schema_editor
):
Document
=
apps
.
get_model
(
'documents'
,
'Document'
)
GeneralMeetingDocument
=
apps
.
get_model
(
'documents'
,
'GeneralMeetingDocument'
)
for
meeting_doc
in
GeneralMeetingDocument
.
objects
.
all
():
name
=
os
.
path
.
basename
(
meeting_doc
.
name
),
doc
=
Document
.
objects
.
create
(
name_en
=
name
,
name_nl
=
name
,
category
=
'misc'
,
file_en
=
meeting_doc
.
file
,
file_nl
=
meeting_doc
.
file
,
members_only
=
True
,
)
meeting_doc
.
meeting
.
documents
.
add
(
doc
)
def
make_minutes_documents
(
apps
,
schema_editor
):
GeneralMeeting
=
apps
.
get_model
(
'documents'
,
'GeneralMeeting'
)
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
,
)
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'documents'
,
'0008_0_refactor_documents'
),
]
operations
=
[
migrations
.
RunPython
(
make_assocation_documents
),
migrations
.
RunPython
(
make_annual_documents
),
migrations
.
RunPython
(
make_general_meeting_documents
),
migrations
.
RunPython
(
make_minutes_documents
),
]
website/documents/migrations/0008_2_refactor_documents.py
0 → 100644
View file @
2c50be56
from
__future__
import
unicode_literals
import
os
import
django.core.validators
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
utils.validators
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'documents'
,
'0008_1_refactor_documents'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'GeneralMeeting'
,
name
=
'minutes'
,
),
migrations
.
DeleteModel
(
name
=
'MiscellaneousDocument'
,
),
migrations
.
DeleteModel
(
name
=
'AssociationDocumentsYear'
,
),
migrations
.
DeleteModel
(
name
=
'GeneralMeetingDocument'
,
),
migrations
.
CreateModel
(
name
=
'MiscellaneousDocument'
,
fields
=
[
],
options
=
{
'verbose_name'
:
'Miscellaneous document'
,
'verbose_name_plural'
:
'Miscellaneous documents'
,
'proxy'
:
True
,
'indexes'
:
[],
},
bases
=
(
'documents.document'
,),
),
]
website/documents/models.py
View file @
2c50be56
from
django.core.validators
import
MinValueValidator
from
django.db
import
models
from
django.urls
import
reverse
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
from
utils.translation
import
ModelTranslateMeta
,
MultilingualField
from
utils.validators
import
validate_file_extension
class
AssociationDocumentsYear
(
models
.
Model
):
year
=
models
.
IntegerField
(
unique
=
True
,
validators
=
[
MinValueValidator
(
1990
)],
)
policy_document
=
models
.
FileField
(
upload_to
=
'documents/association/'
,
validators
=
[
validate_file_extension
],
blank
=
True
,
class
Document
(
models
.
Model
,
metaclass
=
ModelTranslateMeta
):
class
Meta
:
verbose_name
=
_
(
'Document'
)
verbose_name_plural
=
_
(
'Documents'
)
DOCUMENT_CATEGORIES
=
(
(
'annual'
,
_
(
'Annual document'
)),
(
'association'
,
_
(
'Association document'
)),
(
'minutes'
,
_
(
'Minutes'
)),
(
'misc'
,
_
(
'Miscellaneous document'
)),
)
annual_report
=
models
.
FileField
(
upload_to
=
'documents/association/'
,
validators
=
[
validate_file_extension
],
blank
=
True
,
name
=
MultilingualField
(
models
.
CharField
,
verbose_name
=
_
(
'name'
),
max_length
=
200
)
financial_report
=
models
.
FileField
(
upload_to
=
'documents/association/'
,
v
alidators
=
[
validate_file_extension
]
,
blank
=
True
,
created
=
models
.
DateTimeField
(
v
erbose_name
=
_
(
'created'
)
,
auto_now_add
=
True
,
)
def
__str__
(
self
):
return
"{}-{}"
.
format
(
self
.
year
,
self
.
year
+
1
)
last_updated
=
models
.
DateTimeField
(
verbose_name
=
_
(
'last updated'
),
auto_now
=
True
)
category
=
models
.
CharField
(
max_length
=
40
,
choices
=
DOCUMENT_CATEGORIES
,
verbose_name
=
_
(
'category'
),
default
=
'misc'
,
)
class
MiscellaneousDocument
(
models
.
Model
):
name
=
models
.
Char
Field
(
max_length
=
200
)
file
=
models
.
FileField
(
upload_to
=
'documents/
miscellaneous/
'
,
file
=
MultilingualField
(
models
.
File
Field
,
verbose_name
=
_
(
'file'
),
upload_to
=
'documents/'
,
validators
=
[
validate_file_extension
],
)
members_only
=
models
.
BooleanField
(
default
=
False
)
members_only
=
models
.
BooleanField
(
verbose_name
=
_
(
'members only'
),
default
=
False
)
def
__str__
(
self
):
return
self
.
name
return
'%s (%s)'
%
(
self
.
name
,
str
(
self
.
created
.
date
()))
def
get_absolute_url
(
self
):
return
reverse
(
'documents:miscellaneous-document'
,
args
=
(
self
.
pk
,))
class
AnnualDocument
(
Document
):
class
Meta
:
verbose_name
=
_
(
'Annual document'
)
verbose_name_plural
=
_
(
'Annual documents'
)
unique_together
=
(
'subcategory'
,
'year'
)
SUBCATEGORIES
=
(
(
'report'
,
_
(
'Annual report'
)),
(
'financial'
,
_
(
'Financial report'
)),
(
'policy'
,
_
(
'Policy document'
)),
)
class
GeneralMeeting
(
models
.
Model
):
minutes
=
models
.
FileField
(
upload_to
=
'documents/meetings/minutes/'
,
validators
=
[
validate_file_extension
],
blank
=
True
,
null
=
True
,
subcategory
=
models
.
CharField
(
max_length
=
40
,
choices
=
SUBCATEGORIES
,
verbose_name
=
_
(
'category'
),