diff --git a/standards/__pycache__/forms.cpython-38.pyc b/standards/__pycache__/forms.cpython-38.pyc index c942996..9d26b79 100644 Binary files a/standards/__pycache__/forms.cpython-38.pyc and b/standards/__pycache__/forms.cpython-38.pyc differ diff --git a/standards/__pycache__/views.cpython-38.pyc b/standards/__pycache__/views.cpython-38.pyc index 4a00f86..ac17bb8 100644 Binary files a/standards/__pycache__/views.cpython-38.pyc and b/standards/__pycache__/views.cpython-38.pyc differ diff --git a/standards/forms.py b/standards/forms.py index 77d6d0d..668e959 100644 --- a/standards/forms.py +++ b/standards/forms.py @@ -16,9 +16,10 @@ class StandardAddStandard(forms.ModelForm): "name" : "Titel", "area" : "Übergeordneter Bereich", "task" : "Aufgabenbereich", - "content": "Inhalt" + "content": "Inhalt", + "public" : "Direkt veröffentlichen?" } - fields = ['name', 'area', 'task', 'content'] + fields = ['name', 'area', 'task', 'content', 'public'] ''' Hier werden die Elemente für die DropDowns erstellt, damit @@ -39,11 +40,11 @@ class StandardAddStandard(forms.ModelForm): self.fields['task'].queryset = Tasks.objects.filter(area__id=areaid).order_by('name') except (ValueError, TypeError): pass - elif self.instance.pk: self.fields['task'].queryset = Tasks.objects.none() + class StandardAddStandardEditor(forms.ModelForm): #content = forms.CharField(widget=CKEditorWidget()) diff --git a/standards/templates/standards/standards_add.html b/standards/templates/standards/standards_add.html index dd316be..3c2fd45 100644 --- a/standards/templates/standards/standards_add.html +++ b/standards/templates/standards/standards_add.html @@ -7,8 +7,6 @@
{% csrf_token %} {{normalForm|crispy}} - -

Wenn ein Standard erstellt wurde, kann er nur von einer Person mit dem Recht Standards bearbeiten und freischalten veröffentlicht werden.


  @@ -37,5 +35,4 @@ $(document).ready(function() { }); }); - {% endblock content %} diff --git a/standards/templates/standards/standards_management.html b/standards/templates/standards/standards_management.html index 63251d8..e71f2af 100644 --- a/standards/templates/standards/standards_management.html +++ b/standards/templates/standards/standards_management.html @@ -101,12 +101,16 @@ @@ -116,6 +120,7 @@ {% endfor %} + diff --git a/standards/views.py b/standards/views.py index 60b239a..2d45238 100644 --- a/standards/views.py +++ b/standards/views.py @@ -53,10 +53,16 @@ def StandardAdd(request): new_standard.task = normalForm.cleaned_data['task'] new_standard.area = normalForm.cleaned_data['area'] new_standard.name = normalForm.cleaned_data['name'] - new_standard.content = editorForm.cleaned_data['content'] + new_standard.content = editorForm.cleaned_data['content'] + new_standard.public = normalForm.cleaned_data['public'] new_standard.save() tempstandardname = normalForm.cleaned_data['name'] - messages.success(request, f'Standard {tempstandardname} hinzugefügt! Dieser muss noch veröffentlicht werden.') + if(new_standard.public and request.user.has_perm('standard-management')): + messages.success(request, f'Standard {tempstandardname} hinzugefügt und veröffentlicht.') + else: + new_standard.public = False + new_standard.save() + messages.success(request, f'Standard {tempstandardname} hinzugefügt! Dieser muss noch veröffentlicht werden.') return redirect('standards') else: diff --git a/users/templates/users/base.html b/users/templates/users/base.html index b096159..4337eab 100644 --- a/users/templates/users/base.html +++ b/users/templates/users/base.html @@ -201,7 +201,7 @@
- +