equal
deleted
inserted
replaced
50 |
50 |
51 class Meta: |
51 class Meta: |
52 model = soc.models.document.Document |
52 model = soc.models.document.Document |
53 |
53 |
54 #: list of model fields which will *not* be gathered by the form |
54 #: list of model fields which will *not* be gathered by the form |
55 exclude = ['author', 'created', 'modified', 'scope'] |
55 exclude = ['author', 'created', 'modified_by', 'modified', 'scope'] |
56 |
56 |
57 def clean_scope_path(self): |
57 def clean_scope_path(self): |
58 scope_path = self.cleaned_data.get('scope_path') |
58 scope_path = self.cleaned_data.get('scope_path') |
59 # TODO(tlarsen): combine path and link_id and check for uniqueness |
59 # TODO(tlarsen): combine path and link_id and check for uniqueness |
60 if not validate.isScopePathFormatValid(scope_path): |
60 if not validate.isScopePathFormatValid(scope_path): |
73 """Django form displayed a Document is edited. |
73 """Django form displayed a Document is edited. |
74 """ |
74 """ |
75 |
75 |
76 doc_key_name = forms.fields.CharField(widget=forms.HiddenInput) |
76 doc_key_name = forms.fields.CharField(widget=forms.HiddenInput) |
77 created_by = forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(), |
77 created_by = forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(), |
|
78 required=False) |
|
79 last_modified_by = forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(), |
78 required=False) |
80 required=False) |
79 |
81 |
80 |
82 |
81 class View(base.View): |
83 class View(base.View): |
82 """View methods for the Document model. |
84 """View methods for the Document model. |
112 """ |
114 """ |
113 |
115 |
114 account = users.get_current_user() |
116 account = users.get_current_user() |
115 user = soc.logic.models.user.logic.getForFields({'account': account}, |
117 user = soc.logic.models.user.logic.getForFields({'account': account}, |
116 unique=True) |
118 unique=True) |
117 fields['author'] = user |
119 if not entity: |
|
120 # new document so set author |
|
121 fields['author'] = user |
|
122 |
|
123 fields['modified_by'] = user |
118 |
124 |
119 def _editGet(self, request, entity, form): |
125 def _editGet(self, request, entity, form): |
120 """See base.View._editGet(). |
126 """See base.View._editGet(). |
121 """ |
127 """ |
122 |
128 |
123 form.fields['created_by'].initial = entity.author.link_id |
129 form.fields['created_by'].initial = entity.author.name |
124 form.fields['doc_key_name'].initial = entity.key().name(), |
130 form.fields['last_modified_by'].initial = entity.modified_by.name |
|
131 form.fields['doc_key_name'].initial = entity.key().name() |
125 |
132 |
126 |
133 |
127 view = View() |
134 view = View() |
128 |
135 |
129 create = view.create |
136 create = view.create |