Bug bei Standard-Ansicht gelöst

Direktes veröffentlichen bei Standards geht jetzt, wird aber auf false gesetzt, sollte der User nicht über ausreichende Rechte verfügen.
This commit is contained in:
Holger Trampe 2019-12-16 20:39:19 +01:00
parent 8458b456d9
commit 67d8e40595
7 changed files with 22 additions and 13 deletions

View File

@ -16,9 +16,10 @@ class StandardAddStandard(forms.ModelForm):
"name" : "Titel", "name" : "Titel",
"area" : "Übergeordneter Bereich", "area" : "Übergeordneter Bereich",
"task" : "Aufgabenbereich", "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 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') self.fields['task'].queryset = Tasks.objects.filter(area__id=areaid).order_by('name')
except (ValueError, TypeError): except (ValueError, TypeError):
pass pass
elif self.instance.pk: elif self.instance.pk:
self.fields['task'].queryset = Tasks.objects.none() self.fields['task'].queryset = Tasks.objects.none()
class StandardAddStandardEditor(forms.ModelForm): class StandardAddStandardEditor(forms.ModelForm):
#content = forms.CharField(widget=CKEditorWidget()) #content = forms.CharField(widget=CKEditorWidget())

View File

@ -7,8 +7,6 @@
<form method="POST" id="taskareaform"> <form method="POST" id="taskareaform">
{% csrf_token %} {% csrf_token %}
{{normalForm|crispy}} {{normalForm|crispy}}
<p>Wenn ein Standard erstellt wurde, kann er nur von einer Person mit dem Recht <i>Standards bearbeiten und freischalten</i> veröffentlicht werden.</p> <p>Wenn ein Standard erstellt wurde, kann er nur von einer Person mit dem Recht <i>Standards bearbeiten und freischalten</i> veröffentlicht werden.</p>
<hr> <hr>
<button type="submit" class="btn btn-success" href="{% url 'standard-add' %} ">Standard anlegen</button>&nbsp; <button type="submit" class="btn btn-success" href="{% url 'standard-add' %} ">Standard anlegen</button>&nbsp;
@ -37,5 +35,4 @@ $(document).ready(function() {
}); });
}); });
</script> </script>
{% endblock content %} {% endblock content %}

View File

@ -101,12 +101,16 @@
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i> <i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
</a> </a>
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink"> <div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
{% if standard.public %} {% if perms.users.standard_management %}
<a class="dropdown-item" href="{% url 'standard-status' standard.pk %}">Veröffentlichung aufheben</a> {% if standard.public %}
{% else %} <a class="dropdown-item" href="{% url 'standard-status' standard.pk %}">Veröffentlichung aufheben</a>
<a class="dropdown-item" href="{% url 'standard-status' standard.pk %}">Veröffentlichen</a> {% else %}
<a class="dropdown-item" href="{% url 'standard-status' standard.pk %}">Veröffentlichen</a>
{% endif %}
{% endif %} {% endif %}
{% if standard.created_standard_by == request.user or perms.users.standard_management %}
<a class="dropdown-item" href="{% url 'standard-update' standard.pk %}">Bearbeiten</a> <a class="dropdown-item" href="{% url 'standard-update' standard.pk %}">Bearbeiten</a>
{% endif %}
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="{% url 'standard-delete' standard.pk %}" >Löschen</a> <a class="dropdown-item text-danger" href="{% url 'standard-delete' standard.pk %}" >Löschen</a>
</div> </div>
@ -116,6 +120,7 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>

View File

@ -53,10 +53,16 @@ def StandardAdd(request):
new_standard.task = normalForm.cleaned_data['task'] new_standard.task = normalForm.cleaned_data['task']
new_standard.area = normalForm.cleaned_data['area'] new_standard.area = normalForm.cleaned_data['area']
new_standard.name = normalForm.cleaned_data['name'] 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() new_standard.save()
tempstandardname = normalForm.cleaned_data['name'] 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') return redirect('standards')
else: else:

View File

@ -201,7 +201,7 @@
<!-- Topbar Search --> <!-- Topbar Search -->
<form class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100 navbar-search"> <form class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100 navbar-search">
<div class="input-group"> <div class="input-group">
<input list="searchres" placeholder="Suche..." id="search_string" onkeyup="javascript:startSearch(this.value)" class="form-control bg-light border-0 small" > <input list="searchres" placeholder="Agenturweite Suche..." id="search_string" onkeyup="javascript:startSearch(this.value)" class="form-control bg-light border-0 small" >
<!-- <!--
<input type="text" onkeyup="javascript:startSearch(this.value)" class="form-control bg-light border-0 small" placeholder="Suche..." aria-label="Suche" aria-describedby="basic-addon2" id="searchfield"> <input type="text" onkeyup="javascript:startSearch(this.value)" class="form-control bg-light border-0 small" placeholder="Suche..." aria-label="Suche" aria-describedby="basic-addon2" id="searchfield">
--> -->