diff --git a/standards/forms.py b/standards/forms.py index c3b4b2d..e38b004 100644 --- a/standards/forms.py +++ b/standards/forms.py @@ -74,6 +74,8 @@ class StandardAddStandard(forms.ModelForm): self.fields['us_ver'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + + class StandardAddStandardEditor(forms.ModelForm): class Meta: @@ -100,8 +102,9 @@ class StandardUpdateStandard(forms.ModelForm): "content": "Inhalt", "freefield_title" : "Titel und Text", "freefield_content" : "", + 'public' : "Veröffentlichen" } - fields = ['name', 'area', 'task', 'content',"freefield_title", "freefield_content"] + fields = ['name', 'area', 'task', 'content',"freefield_title", "freefield_content", 'public'] ''' Hier werden die Elemente für die DropDowns erstellt, damit @@ -143,6 +146,21 @@ class StandardUpdateStandard(forms.ModelForm): #self.fields['executor'].queryset = UserFullName.objects.filter(profile__agency__pk=loggeduser.profile.agency.pk) #self.fields['authority'].queryset = UserFullName.objects.filter(profile__agency__pk=loggeduser.profile.agency.pk) + self.fields['checked_groups'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['added_files'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['added_standards'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + + self.fields['added_quicklinks'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['added_contacts'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['added_passwords'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + + self.fields['us_verant'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['us_ex'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['us_ver'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + + self.fields['checked_networks'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + + self.fields['public'] = forms.BooleanField(initial=standard.public, required=False) class StandardUpdateStandardEditor(forms.ModelForm): diff --git a/standards/templates/standards/standards_add.html b/standards/templates/standards/standards_add.html index 4ddf249..4278a1d 100644 --- a/standards/templates/standards/standards_add.html +++ b/standards/templates/standards/standards_add.html @@ -2,8 +2,13 @@ {% load crispy_forms_tags %} {% load counter_tag %} {% block content %} -
+
+ + {% if update == True %} +

Standard Bearbeiten{% if request.user.profile.showtooltips %} {% endif %}

+ {% else %}

Neuen Standard anlegen{% if request.user.profile.showtooltips %} {% endif %}

+ {% endif %}
{% csrf_token %} @@ -12,11 +17,11 @@ {% if field.is_hidden == False %} {% if forloop.counter|divisibleby:6 %}
- {% if field.name != 'freefield_content' and field.name != 'freefield_title' %} + {% if field.name != 'freefield_content' and field.name != 'freefield_title' and field.name != 'public' %} {{field|as_crispy_field }} {% endif %} {% else %} - {% if field.name != 'freefield_content' and field.name != 'freefield_title' %} + {% if field.name != 'freefield_content' and field.name != 'freefield_title' and field.name != 'public' %} {{field|as_crispy_field }} {% endif %} {% endif %} @@ -77,15 +82,26 @@
-
+
- {% for s in standards %} - + {% if update == True %} + {% for s in standard_possible %} + {% endfor %} + {% else %} + {% for s in standards %} + + {% endfor %} + {% endif %}
Verlinkte Standards: - +
+ {% if update == True %} + {% for s in standard.linked_standards.all %} + + {% endfor %} + {% endif %}
{{s.name}}
@@ -134,6 +150,11 @@ Verlinkte Dateien: + {% if update == True %} + {% for f in standard.addedfiles.all %} + + {% endfor %} + {% endif %}
{{f.name}}
@@ -142,8 +163,7 @@   klicken/hineinziehen

Dateien werden im Uploadordner für Standards gespeichert.

- {% endif %} - + {% endif %} @@ -162,13 +182,13 @@
-
- {% for g in agencygroups %} -
- - -
- {% endfor %} +
+ {% for g in agencygroups %} +
+ + +
+ {% endfor %}
@@ -184,15 +204,45 @@
- Das Zuweisen zu einem Agenturverbund ist erst nach dem Anlegen eines neuen Standards möglich. + {% if update == True %} + + {% if not standard.public %} + Nur veröffentlichte Standards können geteilt werden. + {% else %} + {% for agn in agencynetworks %} + {% ifaginadminagn agn.pk request.user.profile.agency.pk as is_admin %} + {% ifsharemember agn.pk request.user.profile.agency.pk as is_sharemember %} + {% ifstandardinagn agn.pk standard.pk as standard_in_agn %} + + {% if is_admin or is_sharemember %} +
+ + +
+ {% else %} +  {{agn.name}} + {% endif %} + {% endfor %} + {% endif %} + + {% else %} + Das Zuweisen zu einem Agenturverbund ist erst nach dem Anlegen eines neuen Standards möglich. + {% endif %}
-

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

+

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

+ + {% if perms.users.standardmanager %} + {{ normalForm.public }} Veröffentlichen + {% endif %} +
-   +   Abbrechen @@ -262,15 +312,29 @@ - {% for us in usersofagency %} - - {% endfor %} + {% if update == True %} + {% for us in poss_verant %} + + {% endfor %} + {% else %} + {% for us in usersofagency %} + + {% endfor %} + {% endif %}
+ {% if update == True %} + {% for auth in standard.authority.all %} + + {{auth.first_name}} {{auth.last_name}}   + + {% endfor %} + + {% endif %}
- - + {% if update == True %} + {% for auth in standard.executor.all %} + {{auth.first_name}} {{auth.last_name}}   + {% endfor %} + {% endif %}
- - - + {% if update == True %} + {% for auth in standard.representative.all %} + {{auth.first_name}} {{auth.last_name}}   + {% endfor %} + {% endif %} + {% if update == True %} + {% for q in possible_quicklinks %} + + {% endfor %} + {% else %} {% for q in quicklinks %} {% endfor %} + {% endif %} Verlinkte Quicklinks: + {% if update == True %} + {% for q in standard.addedquicklinks.all %} + + {% endfor %} + {% endif %} + {% if update == True %} + {% for q in possible_contacts %} + + {% endfor %} + {% else %} {% for q in contacts %} {% endfor %} + {% endif %} Verlinkte Kontakte: + {% if update == True %} + {% for q in standard.addedcontacts.all %} + + {% endfor %} + {% endif %}
{{q.company}}
+ {% if update == True %} + {% for q in possible_passwords %} + + {% endfor %} + {% else %} {% for q in passwords %} {% endfor %} + {% endif %} Verlinkte Passwörter: + {% if update == True %} + {% for q in standard.addedpasswords.all %} + + {% endfor %} + {% endif %}
{{q.name}}
@@ -475,9 +589,11 @@ if ( isIE ) { { alluserfields = $(".searchuserfieldstask").each(function(key, value){ specific_userfield_id = value['id'].split("_")[1]; - updateLinkedStandards(); - updateLinkedQuicklinks(); - updateLinkedFiles(); + updateLinkedElements("standards"); + updateLinkedElements("files"); + updateLinkedElements("quicklinks"); + updateLinkedElements("passwords"); + updateLinkedElements("contacts"); checkUserVerant(); checkUserEx(); checkUserVer(); @@ -488,6 +604,14 @@ if ( isIE ) { //USERSTOSTANDARDS //Verantwortlicher act_verant = []; +{% if update == True %} + act_verant = [ + {% for auth in standard.authority.all %} + '{{auth.pk}}', + {% endfor %} + ]; + $("#id_us_verant").val(act_verant); +{% endif %} function checkUserVerant(){ var g = $('#searchuser_verant').val(); var id = $('#possusers_verant').find('option[value="' + g + '"]').attr('id'); @@ -499,7 +623,6 @@ function checkUserVerant(){ act_verant.push(tempid); $("#id_us_verant").val(act_verant); } - } function removeUserFromVeran(id, name){ @@ -507,13 +630,20 @@ function removeUserFromVeran(id, name){ act_verant.splice(index_to_rem,1); $('#possusers_verant').append(''); $("#id_us_verant").val(act_verant); - $("#span_btn_verant_" + id).remove(); - + $("#span_btn_verant_" + id).remove(); } //Ausführender act_ex = []; +{% if update == True %} + act_ex = [ + {% for ex in standard.executor.all %} + '{{ex.pk}}', + {% endfor %} + ]; + $("#id_us_ex").val(act_ex); +{% endif %} function checkUserEx(){ var g = $('#searchuser_ex').val(); var id = $('#possusers_ex').find('option[value="' + g + '"]').attr('id'); @@ -524,21 +654,29 @@ function checkUserEx(){ $("#" + tempid + "_ex").remove(); act_ex.push(tempid); $("#id_us_ex").val(act_ex); - } - + } } function removeUserFromEx(id, name){ index_to_rem = act_ex.indexOf(id.toString()); act_ex.splice(index_to_rem,1); + console.log(name) $('#possusers_ex').append(''); $("#id_us_ex").val(act_ex); - $("#span_btn_ex_" + id).remove(); - + $("#span_btn_ex_" + id).remove(); } //Vertreter act_ver = []; +{% if update == True %} + act_ver = [ + {% for rep in standard.representative.all %} + '{{rep.pk}}', + + {% endfor %} + ]; + $("#id_us_ver").val(act_ver); +{% endif %} function checkUserVer(){ var g = $('#searchuser_ver').val(); var id = $('#possusers_ver').find('option[value="' + g + '"]').attr('id'); @@ -549,8 +687,7 @@ function checkUserVer(){ $("#" + tempid + "_ver").remove(); act_ver.push(tempid); $("#id_us_ver").val(act_ver); - } - + } } function removeUserFromVer(id, name){ @@ -558,8 +695,7 @@ function removeUserFromVer(id, name){ act_ver.splice(index_to_rem,1); $('#possusers_ver').append(''); $("#id_us_ver").val(act_ver); - $("#span_btn_ver_" + id).remove(); - + $("#span_btn_ver_" + id).remove(); } @@ -587,19 +723,68 @@ function changeAddedUsers(){ //Helpfer function to check actual field content function showAllFields(){ - console.log(actualStandards); - console.log(actualFiles); - console.log(actualQuicklinks); - console.log(actualContacts); - console.log(actualPasswords); + console.log($("#id_added_standards").val()); + console.log($("#id_added_files").val()); + console.log($("#id_added_quicklinks").val()); + console.log($("#id_added_contacts").val()); + console.log($("#id_added_passwords").val()); + console.log($("#id_us_verant").val()); + console.log($("#id_us_ver").val()); + console.log($("#id_us_ex").val()); } //STANDARDS actualStandards = []; +{% if update == True %} + actualStandards = [ + {% for s in standard.linked_standards.all %} + '{{s.pk}}', + {% endfor %} + ]; + $("#id_added_standards").val(actualStandards); +{% endif %} + actualFiles = []; +{% if update == True %} + actualFiles = [ + {% for f in standard.addedfiles.all %} + '{{f.pk}}', + {% endfor %} + ]; + $("#id_added_files").val(actualFiles); +{% endif %} + actualQuicklinks = []; +{% if update == True %} + actualQuicklinks = [ + {% for f in standard.addedquicklinks.all %} + '{{f.pk}}', + {% endfor %} + ]; + $("#id_added_quicklinks").val(actualQuicklinks); +{% endif %} + actualContacts = []; +{% if update == True %} + actualContacts = [ + {% for f in standard.addedcontacts.all %} + '{{f.pk}}', + {% endfor %} + ]; + $("#id_added_contacts").val(actualContacts); +{% endif %} + actualPasswords = []; +{% if update == True %} + actualPasswords = [ + {% for f in standard.addedpasswords.all %} + '{{f.pk}}', + {% endfor %} + ]; + $("#id_added_passwords").val(actualPasswords); +{% endif %} + + //Clear the Searchfield with the given type function clearSearchField(type){ @@ -641,7 +826,7 @@ function updateLinkedElements(type){ $("#linked_" + type).append('' + g + ''); } - //showAllFields(); + showAllFields(); } //Remove an added Element from View and placeholder-arrays and hidden fields @@ -677,7 +862,7 @@ function remEle(type, id, name){ $('#poss_' + type).prepend(''); $("#added_" + type + '_' + id).remove(); - //showAllFields(); + showAllFields(); } @@ -825,6 +1010,15 @@ function doUploadAction(filetodo, replacestat){ //GROUPS actualGroups = []; +{% if update == True %} + actualGroups = [ + {% for f in standard.visibleby.all %} + '{{f.pk}}', + {% endfor %} + ]; + $("#id_checked_groups").val(actualGroups); +{% endif %} + function groupsChange(groupid, value){ if(value){ actualGroups.push(groupid); @@ -833,9 +1027,39 @@ function groupsChange(groupid, value){ index_to_rem = actualGroups.indexOf(groupid) actualGroups.splice(index_to_rem,1); } - $("#id_checked_groups").val(actualGroups); + $("#id_checked_groups").val(actualGroups); } + + +{% if update == True %} + +actualNetworks = []; + actualNetworks = [ + {% for agn in agencynetworks %} + {% if standard in agn.standards.all %} + '{{agn.pk}}', + {% endif %} + {% endfor %} + ]; + $("#id_checked_networks").val(actualNetworks); + + +//AGENCYNETWORK +function standardAgn(id, newstat){ + if(newstat){ + actualNetworks.push(id); + } + else { + index_to_rem = actualNetworks.indexOf(id) + actualNetworks.splice(index_to_rem,1); + } + $("#id_checked_networks").val(actualNetworks); +} + + +{% endif %} + /* Ajax-Request zum nachladen der Aufgaben nach Auswahl der Bereiche */ diff --git a/standards/templates/standards/standards_management.html b/standards/templates/standards/standards_management.html index 9582846..27919b9 100644 --- a/standards/templates/standards/standards_management.html +++ b/standards/templates/standards/standards_management.html @@ -26,7 +26,7 @@ - {% if perms.users.standard_management %} + {% if perms.users.standardmanager %} @@ -114,8 +114,8 @@ {% if standard.area != None and standard.task != None %} {{standard.name}} {% else %} - {% if standard.created_standard_by == request.user or perms.users.standard_management %} - {{standard.name}}  + {% if standard.created_standard_by == request.user or perms.users.standardmanager %} + {{standard.name}}  {% else %} {{standard.name}}  {% endif %} @@ -131,7 +131,7 @@