Standardumbau fertig
This commit is contained in:
parent
6363b110bc
commit
e68c374664
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,13 @@
|
|||
{% load crispy_forms_tags %}
|
||||
{% load counter_tag %}
|
||||
{% block content %}
|
||||
<div class="content-section col-12">
|
||||
<div class="content-section col-12">
|
||||
|
||||
{% if update == True %}
|
||||
<h3>Standard Bearbeiten{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Bearbeiten Sie hier einen bestehenden Standard." class="far fa-question-circle"></i></small>{% endif %}</h3>
|
||||
{% else %}
|
||||
<h3>Neuen Standard anlegen{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Legen Sie hier einen neuen Standard an." class="far fa-question-circle"></i></small>{% endif %}</h3>
|
||||
{% endif %}
|
||||
<hr>
|
||||
<form method="POST" id="addstandardform">
|
||||
{% csrf_token %}
|
||||
|
|
@ -12,11 +17,11 @@
|
|||
{% if field.is_hidden == False %}
|
||||
{% if forloop.counter|divisibleby:6 %}
|
||||
</div><div class="col-3">
|
||||
{% 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 @@
|
|||
<input class="form-control" list="poss_standards" id="searchfield_standards" type="text" onkeyup="javascript:updateLinkedElements('standards')" >
|
||||
<div class="input-group-append">
|
||||
<button type="button" onclick="javascript:clearSearchField('standards')" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<datalist id="poss_standards">
|
||||
{% for s in standards %}
|
||||
<option id="standards_{{s.pk}}" value="{{s.name|truncatechars:30}}">{{s.name|truncatechars:30}}</option>
|
||||
{% if update == True %}
|
||||
{% for s in standard_possible %}
|
||||
<option id="standards_{{s.pk}}" value="{{s.name|truncatechars:30}}">{{s.name|truncatechars:30}}</option>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for s in standards %}
|
||||
<option id="standards_{{s.pk}}" value="{{s.name|truncatechars:30}}">{{s.name|truncatechars:30}}</option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</datalist>
|
||||
</div>
|
||||
Verlinkte Standards:
|
||||
<table id="linked_standards" class="table table-hover table-sm">
|
||||
<table id="linked_standards" class="table table-hover table-sm">
|
||||
{% if update == True %}
|
||||
{% for s in standard.linked_standards.all %}
|
||||
<tr id="added_standards_{{s.pk}}"><td>{{s.name}}</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remEle('standards',{{s.pk}}, '{{s.name}}')"><i class="fas fa-trash-alt"></i></button></td></tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -134,6 +150,11 @@
|
|||
</div>
|
||||
Verlinkte Dateien:
|
||||
<table id="linked_files" class="table table-hover table-sm">
|
||||
{% if update == True %}
|
||||
{% for f in standard.addedfiles.all %}
|
||||
<tr id="added_files_{{f.pk}}"><td>{{f.name}}</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remEle('files',{{f.pk}}, '{{f.name}}')"><i class="fas fa-trash-alt"></i></button></td></tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</table>
|
||||
|
||||
<input type="file" id="uploadedfile" name="uploadedfile" style="display:none">
|
||||
|
|
@ -142,8 +163,7 @@
|
|||
<button type="button" class="btn btn-primary btn-sm" id="uploadButton" onclick="javascript:uploadButtonPush()"><i class="fas fa-plus"></i></button> <small>klicken/hineinziehen<p class="mt-2">Dateien werden im <b>Uploadordner für Standards</b> gespeichert.
|
||||
</small></p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -162,13 +182,13 @@
|
|||
</div>
|
||||
|
||||
<div id="stgroups_content" class="collapse" aria-labelledby="st_groups" data-parent="#additionalStandardInfos">
|
||||
<div class="card-body">
|
||||
{% for g in agencygroups %}
|
||||
<div class="custom-control custom-checkbox mb-2">
|
||||
<input type="checkbox" class="custom-control-input groupclass" onclick="javascript:groupsChange({{g.pk}}, this.checked)" name="group_{{g.pk}}" id="group_{{g.pk}}">
|
||||
<label class="custom-control-label" for="group_{{g.pk}}" >{{g.agencygroupname}}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="card-body">
|
||||
{% for g in agencygroups %}
|
||||
<div class="custom-control custom-checkbox mb-2">
|
||||
<input type="checkbox" class="custom-control-input groupclass" onclick="javascript:groupsChange({{g.pk}}, this.checked)" name="group_{{g.pk}}" id="group_{{g.pk}}" {% if g in standard.visibleby.all %} checked {% endif %}>
|
||||
<label class="custom-control-label" for="group_{{g.pk}}" >{{g.agencygroupname}}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -184,15 +204,45 @@
|
|||
</div>
|
||||
<div id="agnetwork_content" class="collapse" aria-labelledby="st_agencynetwork" data-parent="#additionalStandardInfos">
|
||||
<div class="card-body">
|
||||
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 %}
|
||||
<div class="custom-control custom-checkbox mb-2">
|
||||
<input type="checkbox" class="custom-control-input groupclass" onclick="javascript:standardAgn({{agn.pk}}, this.checked)" name="agn_{{agn.pk}}" id="agn_{{agn.pk}}" {% if standard_in_agn %} checked {% endif %} >
|
||||
<label class="custom-control-label" for="agn_{{agn.pk}}" >{{agn.name}}</label>
|
||||
</div>
|
||||
{% else %}
|
||||
<i class="fas fa-lock" data-toggle="tooltip" data-placement="top" title="In diesen Verbund dürfen Sie nichts teilen."></i> {{agn.name}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
Das Zuweisen zu einem Agenturverbund ist erst nach dem Anlegen eines neuen Standards möglich.
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div></div>
|
||||
<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/bearbeitet wurde, kann er nur von einer Person mit dem Recht <i>Standards bearbeiten und freischalten</i> veröffentlicht werden.</p>
|
||||
|
||||
{% if perms.users.standardmanager %}
|
||||
{{ normalForm.public }} Veröffentlichen
|
||||
{% endif %}
|
||||
|
||||
<hr>
|
||||
<button type="submit" class="btn btn-success">Standard anlegen</button>
|
||||
<button type="submit" class="btn btn-success">
|
||||
Standard{% if update == True %} aktualisieren{% else %} anlegen{% endif %}
|
||||
</button>
|
||||
<a class="btn" href="{% url 'standards' %} ">Abbrechen</a>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -262,15 +312,29 @@
|
|||
<button type="button" onclick="javascript:clearUserSearchFields('verant')" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<datalist id="possusers_verant">
|
||||
{% for us in usersofagency %}
|
||||
<option id="{{us.pk}}_verant" value="{{us.first_name}} {{us.last_name}}"></option>
|
||||
{% endfor %}
|
||||
{% if update == True %}
|
||||
{% for us in poss_verant %}
|
||||
<option id="{{us.pk}}_verant" value="{{us.first_name}} {{us.last_name}}"></option>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for us in usersofagency %}
|
||||
<option id="{{us.pk}}_verant" value="{{us.first_name}} {{us.last_name}}"></option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<!--<h6>Verantwortliche Mitarbeiter:</h6>-->
|
||||
<div id="added_users_verant_buttons"></div>
|
||||
{% if update == True %}
|
||||
|
||||
{% for auth in standard.authority.all %}
|
||||
|
||||
<span id="span_btn_verant_{{auth.pk}}" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromVeran({{auth.pk}}, '{{auth.first_name}} {{auth.last_name}}')">{{auth.first_name}} {{auth.last_name}} <i class="fas fa-times"></i></a ></span>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
<hr>
|
||||
<!--
|
||||
Ausführender
|
||||
|
|
@ -283,16 +347,25 @@
|
|||
<button type="button" onclick="javascript:clearUserSearchFields('ex')" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<datalist id="possusers_ex">
|
||||
{% for us in usersofagency %}
|
||||
<option id="{{us.pk}}_ex" value="{{us.first_name}} {{us.last_name}}"></option>
|
||||
{% endfor %}
|
||||
{% if update == True %}
|
||||
{% for us in poss_ex %}
|
||||
<option id="{{us.pk}}_ex" value="{{us.first_name}} {{us.last_name}}"></option>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for us in usersofagency %}
|
||||
<option id="{{us.pk}}_ex" value="{{us.first_name}} {{us.last_name}}"></option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<!--<h6>Ausführende Mitarbeiter:</h6>-->
|
||||
<div id="added_users_ex_buttons"></div>
|
||||
|
||||
|
||||
{% if update == True %}
|
||||
{% for auth in standard.executor.all %}
|
||||
<span id="span_btn_ex_{{auth.pk}}" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromEx({{auth.pk}}, '{{auth.first_name}} {{auth.last_name}}')">{{auth.first_name}} {{auth.last_name}} <i class="fas fa-times"></i></a ></span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<hr>
|
||||
<!--
|
||||
Vertreter
|
||||
|
|
@ -304,17 +377,25 @@
|
|||
<button type="button" onclick="javascript:clearUserSearchFields('ver')" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<datalist id="possusers_ver">
|
||||
{% for us in usersofagency %}
|
||||
<option id="{{us.pk}}_ver" value="{{us.first_name}} {{us.last_name}}"></option>
|
||||
{% endfor %}
|
||||
{% if update == True %}
|
||||
{% for us in poss_ver %}
|
||||
<option id="{{us.pk}}_ver" value="{{us.first_name}} {{us.last_name}}"></option>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for us in usersofagency %}
|
||||
<option id="{{us.pk}}_ver" value="{{us.first_name}} {{us.last_name}}"></option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<!--<h6>Vertretende Mitarbeiter:</h6>-->
|
||||
<div id="added_users_ver_buttons"></div>
|
||||
|
||||
|
||||
|
||||
{% if update == True %}
|
||||
{% for auth in standard.representative.all %}
|
||||
<span id="span_btn_ver_{{auth.pk}}" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromVer({{auth.pk}}, '{{auth.first_name}} {{auth.last_name}}')">{{auth.first_name}} {{auth.last_name}} <i class="fas fa-times"></i></a ></span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-success" data-dismiss="modal">Fertig</button>
|
||||
|
|
@ -382,13 +463,24 @@
|
|||
<button type="button" onclick="javascript:clearSearchField('quicklinks')" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<datalist id="poss_quicklinks">
|
||||
{% if update == True %}
|
||||
{% for q in possible_quicklinks %}
|
||||
<option id="quicklinks_{{q.pk}}" value="{{q.name}}">{{q.name}}</option>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for q in quicklinks %}
|
||||
<option id="quicklinks_{{q.pk}}" value="{{q.name}}">{{q.name}}</option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</datalist>
|
||||
</div>
|
||||
Verlinkte Quicklinks:
|
||||
<table id="linked_quicklinks" class="table table-hover table-sm">
|
||||
{% if update == True %}
|
||||
{% for q in standard.addedquicklinks.all %}
|
||||
<tr id="added_quicklinks_{{q.pk}}"><td>{{q.name}}</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remEle('quicklinks',{{q.pk}}, '{{q.name}}')"><i class="fas fa-trash-alt"></i></button></td></tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
|
@ -415,13 +507,24 @@
|
|||
<button type="button" onclick="javascript:clearSearchField('contacts')" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<datalist id="poss_contacts">
|
||||
{% if update == True %}
|
||||
{% for q in possible_contacts %}
|
||||
<option id="contacts_{{q.pk}}" value="{{q.company}}">{{q.company}}</option>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for q in contacts %}
|
||||
<option id="contacts_{{q.pk}}" value="{{q.company}}">{{q.company}}</option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</datalist>
|
||||
</div>
|
||||
Verlinkte Kontakte:
|
||||
<table id="linked_contacts" class="table table-hover table-sm">
|
||||
{% if update == True %}
|
||||
{% for q in standard.addedcontacts.all %}
|
||||
<tr id="added_contacts_{{q.pk}}"><td>{{q.company}}</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remEle('contacts',{{q.pk}}, '{{q.company}}')"><i class="fas fa-trash-alt"></i></button></td></tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
|
@ -448,13 +551,24 @@
|
|||
<button type="button" onclick="javascript:clearSearchField('passwords')" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
<datalist id="poss_passwords">
|
||||
{% if update == True %}
|
||||
{% for q in possible_passwords %}
|
||||
<option id="passwords_{{q.pk}}" value="{{q.name}}">{{q.name}}</option>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for q in passwords %}
|
||||
<option id="passwords_{{q.pk}}" value="{{q.name}}">{{q.name}}</option>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</datalist>
|
||||
</div>
|
||||
Verlinkte Passwörter:
|
||||
<table id="linked_passwords" class="table table-hover table-sm">
|
||||
{% if update == True %}
|
||||
{% for q in standard.addedpasswords.all %}
|
||||
<tr id="added_passwords_{{q.pk}}"><td>{{q.name}}</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remEle('passwords',{{q.pk}}, '{{q.name}}')"><i class="fas fa-trash-alt"></i></button></td></tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
|
@ -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('<option id="'+id+'_verant" value="'+ name +'">'+ name +'</option>');
|
||||
$("#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('<option id="'+id+'_ex" value="'+ name +'">'+ name +'</option>');
|
||||
$("#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('<option id="'+id+'_ver" value="'+ name +'">'+ name +'</option>');
|
||||
$("#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('<tr id="added_'+ type +'_' + tempid+'"><td>' + g + '</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remEle(\''+type+'\','+tempid+', \''+g+'\')"><i class="fas fa-trash-alt"></i></button></td></tr>');
|
||||
}
|
||||
|
||||
//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('<option id="'+type+'_'+id+'" value="'+ name +'">'+ name +'</option>');
|
||||
$("#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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
<li class="nav-item" >
|
||||
<a class="nav-link" id="userown" data-toggle="tab" href="#t_userown" role="tab" aria-controls="t_userown" aria-selected="false">Eigene Standards</a>
|
||||
</li>
|
||||
{% if perms.users.standard_management %}
|
||||
{% if perms.users.standardmanager %}
|
||||
<li class="nav-item" style="float: right !important;">
|
||||
<a class="nav-link" id="agencys" data-toggle="tab" href="#t_agencys" role="tab" aria-controls="t_agencys" aria-selected="false">Unveröffentlichte Standards {% if unpubstandards_of_user|length > 0 %} ({{unpubstandards_of_user|length}}) {%endif%}</a>
|
||||
</li>
|
||||
|
|
@ -114,8 +114,8 @@
|
|||
{% if standard.area != None and standard.task != None %}
|
||||
<a href="{% url 'standard-single' standard.pk %}">{{standard.name}}</a>
|
||||
{% else %}
|
||||
{% if standard.created_standard_by == request.user or perms.users.standard_management %}
|
||||
<a href="{% url 'standard-update' standard.pk %}">{{standard.name}}</a> <i class="fas fa-exclamation-circle"data-toggle="tooltip" data-placement="top" title="Es wurden nicht alle Pflichtfelder ausgefüllt."></i>
|
||||
{% if standard.created_standard_by == request.user or perms.users.standardmanager %}
|
||||
<a href="{% url 'standard-add' standard.pk %}">{{standard.name}}</a> <i class="fas fa-exclamation-circle"data-toggle="tooltip" data-placement="top" title="Es wurden nicht alle Pflichtfelder ausgefüllt."></i>
|
||||
{% else %}
|
||||
{{standard.name}} <i class="fas fa-exclamation-circle"data-toggle="tooltip" data-placement="top" title="Es wurden nicht alle Pflichtfelder ausgefüllt."></i>
|
||||
{% endif %}
|
||||
|
|
@ -131,7 +131,7 @@
|
|||
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
|
||||
{% if perms.users.standard_management %}
|
||||
{% if perms.users.standardmanager %}
|
||||
{% if standard.public %}
|
||||
<a class="dropdown-item" href="{% url 'standard-status' standard.pk %}">Veröffentlichung aufheben</a>
|
||||
{% else %}
|
||||
|
|
@ -140,8 +140,8 @@
|
|||
{% 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>
|
||||
{% if standard.created_standard_by == request.user or perms.users.standardmanager %}
|
||||
<a class="dropdown-item" href="{% url 'standard-add' standard.pk %}">Bearbeiten</a>
|
||||
{% endif %}
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger" href="{% url 'standard-delete' standard.pk %}" >Löschen</a>
|
||||
|
|
@ -179,7 +179,7 @@
|
|||
{% if standard.area != None and standard.task != None %}
|
||||
<a href="{% url 'standard-single' standard.pk %}">{{standard.name}}</a>
|
||||
{% else %}
|
||||
{% if standard.created_standard_by == request.user or perms.users.standard_management %}
|
||||
{% if standard.created_standard_by == request.user or perms.users.standardmanager %}
|
||||
<a href="{% url 'standard-update' standard.pk %}">{{standard.name}}</a> <i class="fas fa-exclamation-circle"data-toggle="tooltip" data-placement="top" title="Es wurden nicht alle Pflichtfelder ausgefüllt."></i>
|
||||
{% else %}
|
||||
{{standard.name}} <i class="fas fa-exclamation-circle"data-toggle="tooltip" data-placement="top" title="Es wurden nicht alle Pflichtfelder ausgefüllt."></i>
|
||||
|
|
@ -196,7 +196,7 @@
|
|||
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
|
||||
{% if perms.users.standard_management %}
|
||||
{% if perms.users.standardmanager %}
|
||||
{% if standard.public %}
|
||||
<a class="dropdown-item" href="{% url 'standard-status' standard.pk %}">Veröffentlichung aufheben</a>
|
||||
{% else %}
|
||||
|
|
@ -205,8 +205,8 @@
|
|||
{% 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>
|
||||
{% if standard.created_standard_by == request.user or perms.users.standardmanager %}
|
||||
<a class="dropdown-item" href="{% url 'standard-add' standard.pk %}">Bearbeiten</a>
|
||||
{% endif %}
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger" href="{% url 'standard-delete' standard.pk %}" >Löschen</a>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<span style="float: right">
|
||||
{% if standard.created_standard_by == user or perms.users.standardmanager %}
|
||||
<a style="float: right" class="btn btn-secondary btn-sm ml-2" href="{% url 'standard-delete' standard.pk %}"><small><i class="fas fa-trash"></i></small></a>
|
||||
<a style="float: right" class="btn btn-secondary btn-sm " href="{% url 'standard-update' standard.pk %}"><small><i class="fas fa-pen"></i></small></a>
|
||||
<a style="float: right" class="btn btn-secondary btn-sm " href="{% url 'standard-add' standard.pk %}"><small><i class="fas fa-pen"></i></small></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</h2>
|
||||
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
|
||||
{% if standard.freefield_title|length > 0 %}
|
||||
<div class="card col-14 ml-1 mb-2" style="">
|
||||
<div class="card col-14 ml-1 mb-2" style="min-width: 110%">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{standard.freefield_title}}</h5>
|
||||
<p class="card-text">
|
||||
|
|
@ -55,19 +55,11 @@
|
|||
|
||||
|
||||
{% if standard.authority.count > 0 or standard.executor.count > 0 or standard.representative.count > 0 %}
|
||||
<div class="card col-14 ml-1 mb-2" style="">
|
||||
<div class="card col-14 ml-1 mb-2" style="min-width: 110%">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Personen</h5>
|
||||
<p class="card-text">
|
||||
|
||||
{% if standard.authority.count > 0 %}
|
||||
Verantwortliche<br />
|
||||
{% for u in standard.authority.all %}
|
||||
<a href="{% url 'orga-single' u.pk%}"> {{u.first_name}} {{u.last_name}}</a>{% if forloop.counter < standard.authority.count%} | {% endif %}
|
||||
{% endfor %}
|
||||
<br />
|
||||
{% endif %}
|
||||
|
||||
{% if standard.executor.count > 0 %}
|
||||
Ausführende<br />
|
||||
{% for u in standard.executor.all %}
|
||||
|
|
@ -85,6 +77,18 @@
|
|||
{% endif %}
|
||||
|
||||
|
||||
{% if standard.authority.count > 0 %}
|
||||
Verantwortliche<br />
|
||||
{% for u in standard.authority.all %}
|
||||
<a href="{% url 'orga-single' u.pk%}"> {{u.first_name}} {{u.last_name}}</a>{% if forloop.counter < standard.authority.count%} | {% endif %}
|
||||
{% endfor %}
|
||||
<br />
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -92,10 +96,9 @@
|
|||
|
||||
|
||||
|
||||
<!-- FILES -->
|
||||
|
||||
<!-- FILES -->
|
||||
{% if standard.addedfiles.all|length > 0 %}
|
||||
<div class="card col-14 ml-1 mb-2" style="">
|
||||
<div class="card col-14 ml-1 mb-2" style="min-width: 110%">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Dateien</h5>
|
||||
<p class="card-text">
|
||||
|
|
@ -109,12 +112,12 @@
|
|||
|
||||
<!-- Quicklinks -->
|
||||
{% if standard.addedquicklinks.all|length > 0 %}
|
||||
<div class="card col-14 ml-1 mb-2" style="">
|
||||
<div class="card col-14 ml-1 mb-2" style="min-width: 110%">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Quicklinks</h5>
|
||||
<p class="card-text">
|
||||
{% for ql in standard.addedquicklinks.all %}
|
||||
<a href="{{ ql.link }}" target="_blank">{{ ql.link|truncatechars:30 }}</a>
|
||||
<a href="{{ ql.link }}" target="_blank">{{ ql.link|truncatechars:30 }}</a><br />
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -124,7 +127,7 @@
|
|||
|
||||
<!-- Contacts -->
|
||||
{% if standard.addedcontacts.all|length > 0 %}
|
||||
<div class="card col-14 ml-1 mb-2" style="">
|
||||
<div class="card col-14 ml-1 mb-2" style="min-width: 110%">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Kontakte</h5>
|
||||
<p class="card-text">
|
||||
|
|
@ -138,7 +141,7 @@
|
|||
|
||||
<!-- Passwords -->
|
||||
{% if standard.addedpasswords.all|length > 0 %}
|
||||
<div class="card col-14 ml-1 mb-2" style="">
|
||||
<div class="card col-14 ml-1 mb-2" style="min-width: 110%">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Passwörter</h5>
|
||||
<p class="card-text">
|
||||
|
|
@ -155,13 +158,11 @@
|
|||
|
||||
<!-- STANDARDS -->
|
||||
{% if standard.linked_standards.all|length > 0 %}
|
||||
<div class="card col-14 ml-1" style="">
|
||||
<div class="card col-14 ml-1" style="min-width: 110%">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Verwandte Standards</h5>
|
||||
<p class="card-text">
|
||||
{% for standard in standard.linked_standards.all %}
|
||||
|
||||
|
||||
{% setbool False %}
|
||||
{% for ag in standard.visibleby.all %}
|
||||
{% if request.user|has_group:ag.group.name %}
|
||||
|
|
@ -211,7 +212,7 @@
|
|||
{% setbool False %}
|
||||
|
||||
{% for passgrous in pass.visibleby.all %}
|
||||
|
||||
|
||||
{% if user|has_group:passgrous.group.name %}
|
||||
{% setbool True %}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ Permissions definiert in models.py bei USERS und dann hier vor die View geschrie
|
|||
urlpatterns = [
|
||||
path('', StandardsManagement.as_view(template_name="standards/standards_management.html"), name='standards'),
|
||||
path('standardadd/', views.StandardAdd, name='standard-add'),
|
||||
path('standardadd/<int:id>', views.StandardAdd, name='standard-add'),
|
||||
path('standardupdate/<int:id>', views.StandardUpdate, name='standard-update'),
|
||||
path('ajax/loadtasks/', views.load_tasks, name='ajax_loadtasks'),
|
||||
path('ajups/<int:pk>', views.updatesbyajax, name='update_standard_by_ajax'),
|
||||
|
|
|
|||
|
|
@ -111,137 +111,338 @@ def checkUserDirRights(request, startdir, userid):
|
|||
|
||||
|
||||
@login_required
|
||||
def StandardAdd(request):
|
||||
if request.method == 'POST':
|
||||
normalForm = StandardAddStandard(request.POST, instance=request.user)
|
||||
editorForm = StandardAddStandardEditor(request.POST, instance=request.user)
|
||||
if editorForm.is_valid() and normalForm.is_valid():
|
||||
normalForm.agency = request.user.profile.agency
|
||||
normalForm.created_standard_by = request.user
|
||||
normalForm.created_standard_date = datetime.now()
|
||||
normalForm.published_by = request.user
|
||||
normalForm.last_modifed_by = request.user
|
||||
normalForm.save()
|
||||
editorForm.save()
|
||||
new_standard = Standards()
|
||||
new_standard.agency = request.user.profile.agency
|
||||
new_standard.created_standard_by = request.user
|
||||
new_standard.published_by = request.user
|
||||
new_standard.last_modified_by = request.user
|
||||
new_standard.created_standard_date = datetime.now()
|
||||
new_standard.last_modified_on = datetime.now()
|
||||
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.public = normalForm.cleaned_data['public']
|
||||
def StandardAdd(request, id=False):
|
||||
# NEW STANDARD
|
||||
if(id == False):
|
||||
if request.method == 'POST':
|
||||
normalForm = StandardAddStandard(request.POST, instance=request.user)
|
||||
editorForm = StandardAddStandardEditor(request.POST, instance=request.user)
|
||||
if editorForm.is_valid() and normalForm.is_valid():
|
||||
normalForm.agency = request.user.profile.agency
|
||||
normalForm.created_standard_by = request.user
|
||||
normalForm.created_standard_date = datetime.now()
|
||||
normalForm.published_by = request.user
|
||||
normalForm.last_modifed_by = request.user
|
||||
normalForm.save()
|
||||
editorForm.save()
|
||||
new_standard = Standards()
|
||||
new_standard.agency = request.user.profile.agency
|
||||
new_standard.created_standard_by = request.user
|
||||
new_standard.published_by = request.user
|
||||
new_standard.last_modified_by = request.user
|
||||
new_standard.created_standard_date = datetime.now()
|
||||
new_standard.last_modified_on = datetime.now()
|
||||
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.public = normalForm.cleaned_data['public']
|
||||
|
||||
new_standard.freefield_content = normalForm.cleaned_data['freefield_content']
|
||||
new_standard.freefield_title = normalForm.cleaned_data['freefield_title']
|
||||
new_standard.freefield_content = normalForm.cleaned_data['freefield_content']
|
||||
new_standard.freefield_title = normalForm.cleaned_data['freefield_title']
|
||||
|
||||
new_standard.save()
|
||||
|
||||
#new_standard.representative.set(normalForm.cleaned_data['representative'])
|
||||
#new_standard.executor.set(normalForm.cleaned_data['executor'])
|
||||
#new_standard.authority.set(normalForm.cleaned_data['authority'])
|
||||
|
||||
# REPRESENTATIV
|
||||
verant = normalForm.cleaned_data['us_verant'].split(",")
|
||||
for v in verant:
|
||||
if(v.isdigit()):
|
||||
new_standard.authority.add(User.objects.get(pk=v))
|
||||
|
||||
# EXECUTORS
|
||||
ex = normalForm.cleaned_data['us_ex'].split(",")
|
||||
for v in ex:
|
||||
if(v.isdigit()):
|
||||
new_standard.executor.add(User.objects.get(pk=v))
|
||||
|
||||
# AUTHORITY
|
||||
ver = normalForm.cleaned_data['us_ver'].split(",")
|
||||
for v in ver:
|
||||
if(v.isdigit()):
|
||||
new_standard.representative.add(User.objects.get(pk=v))
|
||||
|
||||
# ADD GROUPS
|
||||
groups = normalForm.cleaned_data['checked_groups'].split(",")
|
||||
|
||||
for g in groups:
|
||||
if(g.isdigit()):
|
||||
new_standard.visibleby.add(AgencyGroup.objects.get(pk=g))
|
||||
|
||||
# ADD STANDARDS
|
||||
standards = normalForm.cleaned_data['added_standards'].split(",")
|
||||
for s in standards:
|
||||
if(s.isdigit()):
|
||||
new_standard.linked_standards.add(Standards.objects.get(pk=s))
|
||||
|
||||
# ADD FILES
|
||||
files = normalForm.cleaned_data['added_files'].split(",")
|
||||
for f in files:
|
||||
if(f.isdigit()):
|
||||
new_standard.addedfiles.add(DataFile.objects.get(pk=f))
|
||||
|
||||
# ADD QUICKLINKS
|
||||
quicklinks = normalForm.cleaned_data['added_quicklinks'].split(",")
|
||||
for f in quicklinks:
|
||||
if(f.isdigit()):
|
||||
new_standard.addedquicklinks.add(QuickLinks.objects.get(pk=f))
|
||||
|
||||
# ADD PASSWORDS
|
||||
addedpasswords = normalForm.cleaned_data['added_passwords'].split(",")
|
||||
for f in addedpasswords:
|
||||
if(f.isdigit()):
|
||||
new_standard.addedpasswords.add(AGPassword.objects.get(pk=f))
|
||||
|
||||
# ADD CONTACTS
|
||||
contacts = normalForm.cleaned_data['added_contacts'].split(",")
|
||||
for f in contacts:
|
||||
if(f.isdigit()):
|
||||
new_standard.addedcontacts.add(AGContacts.objects.get(pk=f))
|
||||
|
||||
|
||||
tempstandardname = normalForm.cleaned_data['name']
|
||||
if(new_standard.public and request.user.has_perm('users.standardmanager')):
|
||||
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:
|
||||
normalForm = StandardAddStandard(instance=request.user)
|
||||
editorForm = StandardAddStandardEditor(instance=request.user)
|
||||
|
||||
|
||||
possibleFilesByVisible = []
|
||||
|
||||
allfiles = DataFile.objects.filter(agency=request.user.profile.agency)
|
||||
|
||||
for f in allfiles:
|
||||
actParent = DataDir.objects.get(pk=f.parent.pk)
|
||||
if actParent.is_root:
|
||||
possibleFilesByVisible.append(f)
|
||||
else:
|
||||
if(checkUserDirRights(request, actParent, request.user.pk)):
|
||||
possibleFilesByVisible.append(f)
|
||||
|
||||
context = {
|
||||
'normalForm' : normalForm,
|
||||
'editorForm' : editorForm,
|
||||
'active_link' : 'standards',
|
||||
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency),
|
||||
'usersofagency' : User.objects.filter(profile__agency=request.user.profile.agency),
|
||||
'files' : possibleFilesByVisible,
|
||||
'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk,
|
||||
'standards' : Standards.objects.filter(agency=request.user.profile.agency, public=True),
|
||||
'quicklinks' : QuickLinks.objects.filter(agency=request.user.profile.agency),
|
||||
'contacts' : AGContacts.objects.filter(agency=request.user.profile.agency),
|
||||
'passwords' : AGPassword.objects.filter(agency=request.user.profile.agency),
|
||||
}
|
||||
return render(request, 'standards/standards_add.html', context)
|
||||
# UPDATE A STANDARD
|
||||
else:
|
||||
standard = Standards.objects.get(pk=id, agency=request.user.profile.agency)
|
||||
# SAVE UPDATED STANDARD
|
||||
if request.method == 'POST':
|
||||
normalForm = StandardUpdateStandard(request.POST, instance=standard)
|
||||
editorForm = StandardUpdateStandardEditor(request.POST, instance=standard)
|
||||
|
||||
if editorForm.is_valid() and normalForm.is_valid():
|
||||
standard.last_modified_by = request.user
|
||||
standard.last_modified_on = datetime.now()
|
||||
standard.task = normalForm.cleaned_data['task']
|
||||
standard.area = normalForm.cleaned_data['area']
|
||||
standard.name = normalForm.cleaned_data['name']
|
||||
standard.public = normalForm.cleaned_data['public']
|
||||
standard.content = editorForm.cleaned_data['content']
|
||||
standard.freefield_content = normalForm.cleaned_data['freefield_content']
|
||||
standard.freefield_title = normalForm.cleaned_data['freefield_title']
|
||||
|
||||
|
||||
# ADD NEW INFOS
|
||||
# REPRESENTATIV
|
||||
verant = normalForm.cleaned_data['us_verant'].split(",")
|
||||
for v in verant:
|
||||
if(v.isdigit()):
|
||||
standard.authority.add(User.objects.get(pk=v))
|
||||
|
||||
# EXECUTORS
|
||||
ex = normalForm.cleaned_data['us_ex'].split(",")
|
||||
for v in ex:
|
||||
if(v.isdigit()):
|
||||
standard.executor.add(User.objects.get(pk=v))
|
||||
|
||||
# AUTHORITY
|
||||
ver = normalForm.cleaned_data['us_ver'].split(",")
|
||||
for v in ver:
|
||||
if(v.isdigit()):
|
||||
standard.representative.add(User.objects.get(pk=v))
|
||||
|
||||
# ADD GROUPS
|
||||
groups = normalForm.cleaned_data['checked_groups'].split(",")
|
||||
|
||||
for g in groups:
|
||||
if(g.isdigit()):
|
||||
standard.visibleby.add(AgencyGroup.objects.get(pk=g))
|
||||
|
||||
# ADD STANDARDS
|
||||
standards = normalForm.cleaned_data['added_standards'].split(",")
|
||||
for s in standards:
|
||||
if(s.isdigit()):
|
||||
standard.linked_standards.add(Standards.objects.get(pk=s))
|
||||
|
||||
# ADD FILES
|
||||
files = normalForm.cleaned_data['added_files'].split(",")
|
||||
for f in files:
|
||||
if(f.isdigit()):
|
||||
standard.addedfiles.add(DataFile.objects.get(pk=f))
|
||||
|
||||
# ADD QUICKLINKS
|
||||
quicklinks = normalForm.cleaned_data['added_quicklinks'].split(",")
|
||||
for f in quicklinks:
|
||||
if(f.isdigit()):
|
||||
standard.addedquicklinks.add(QuickLinks.objects.get(pk=f))
|
||||
|
||||
# ADD PASSWORDS
|
||||
addedpasswords = normalForm.cleaned_data['added_passwords'].split(",")
|
||||
for f in addedpasswords:
|
||||
if(f.isdigit()):
|
||||
standard.addedpasswords.add(AGPassword.objects.get(pk=f))
|
||||
|
||||
# ADD CONTACTS
|
||||
contacts = normalForm.cleaned_data['added_contacts'].split(",")
|
||||
for f in contacts:
|
||||
if(f.isdigit()):
|
||||
standard.addedcontacts.add(AGContacts.objects.get(pk=f))
|
||||
|
||||
# ADD TO NETWORKS
|
||||
networks = normalForm.cleaned_data['checked_networks'].split(",")
|
||||
for f in networks:
|
||||
if(f.isdigit()):
|
||||
tempnetwork = AgencyNetwork.objects.get(pk=f)
|
||||
tempnetwork.standards.add(standard)
|
||||
|
||||
if request.user.has_perm('users.standardmanager'):
|
||||
messages.success(request, f'Standard {standard.name} aktualisiert!')
|
||||
else:
|
||||
if standard.public:
|
||||
standard.public = False
|
||||
messages.warning(request, f'Standard <a href="#">{standard.name}</a> aktualisiert und ist nicht mehr öffentlich, damit Änderungen geprüft werden können.')
|
||||
else:
|
||||
messages.success(request, f'Standard <a href="#">{standard.name}</a> aktualisiert!')
|
||||
standard.save()
|
||||
return redirect('/standards')
|
||||
# SHOW EXISTING STANDARD
|
||||
else:
|
||||
normalForm = StandardUpdateStandard(instance=standard)
|
||||
editorForm = StandardUpdateStandardEditor(instance=standard)
|
||||
# GET ALL DATAS FROM STANDARD
|
||||
# FILES
|
||||
possibleFilesByVisible = []
|
||||
|
||||
allfiles = DataFile.objects.filter(agency=request.user.profile.agency)
|
||||
# Get all files by view
|
||||
for f in allfiles:
|
||||
actParent = DataDir.objects.get(pk=f.parent.pk)
|
||||
if actParent.is_root:
|
||||
possibleFilesByVisible.append(f)
|
||||
else:
|
||||
if(checkUserDirRights(request, actParent, request.user.pk)):
|
||||
possibleFilesByVisible.append(f)
|
||||
|
||||
# Remove files which are in standard
|
||||
for f in possibleFilesByVisible:
|
||||
if f in standard.addedfiles.all():
|
||||
possibleFilesByVisible.remove(f)
|
||||
|
||||
|
||||
# STANDARDS
|
||||
possible_standards = []
|
||||
allstandards = Standards.objects.filter(agency=request.user.profile.agency, public=True)
|
||||
|
||||
for s in allstandards:
|
||||
if s not in standard.linked_standards.all():
|
||||
possible_standards.append(s)
|
||||
|
||||
|
||||
# USERS VER AUTH EX
|
||||
possible_verant = User.objects.filter(profile__agency__pk=request.user.profile.agency.pk)
|
||||
possible_verant_final = []
|
||||
for pv in possible_verant:
|
||||
if pv not in standard.authority.all():
|
||||
possible_verant_final.append(pv)
|
||||
|
||||
possible_ex = User.objects.filter(profile__agency__pk=request.user.profile.agency.pk)
|
||||
possible_ex_final = []
|
||||
for pv in possible_ex:
|
||||
if pv not in standard.executor.all():
|
||||
possible_ex_final.append(pv)
|
||||
|
||||
possible_ver = User.objects.filter(profile__agency__pk=request.user.profile.agency.pk)
|
||||
possible_ver_final = []
|
||||
for pv in possible_ver:
|
||||
if pv not in standard.representative.all():
|
||||
possible_ver_final.append(pv)
|
||||
|
||||
# QUICKLINKS
|
||||
possible_quicklinks = []
|
||||
quicklinks = QuickLinks.objects.filter(agency=request.user.profile.agency)
|
||||
|
||||
for q in quicklinks:
|
||||
if q not in standard.addedquicklinks.all():
|
||||
possible_quicklinks.append(q)
|
||||
|
||||
# CONTACTS
|
||||
possible_contacts = []
|
||||
contacts = AGContacts.objects.filter(agency=request.user.profile.agency)
|
||||
|
||||
for q in contacts:
|
||||
if q not in standard.addedcontacts.all():
|
||||
possible_contacts.append(q)
|
||||
|
||||
# PASSWORDS
|
||||
possible_passwords = []
|
||||
contacts = AGPassword.objects.filter(agency=request.user.profile.agency)
|
||||
|
||||
for q in contacts:
|
||||
if q not in standard.addedpasswords.all():
|
||||
possible_passwords.append(q)
|
||||
|
||||
# AGENCYNETWORKS
|
||||
|
||||
agencynetworks_all = AgencyNetwork.objects.all()
|
||||
agencynetworks = []
|
||||
|
||||
for a in agencynetworks_all:
|
||||
if request.user.profile.agency in a.adminagencys.all() or request.user.profile.agency in a.members.all() or request.user.profile.agency in a.sharemembers.all():
|
||||
agencynetworks.append(a)
|
||||
|
||||
# GROUPS
|
||||
new_standard.save()
|
||||
# Nicht nötig, da alles über agencygroups und direkt im Standard gemacht wird
|
||||
|
||||
#new_standard.representative.set(normalForm.cleaned_data['representative'])
|
||||
#new_standard.executor.set(normalForm.cleaned_data['executor'])
|
||||
#new_standard.authority.set(normalForm.cleaned_data['authority'])
|
||||
|
||||
# REPRESENTATIV
|
||||
verant = normalForm.cleaned_data['us_verant'].split(",")
|
||||
for v in verant:
|
||||
if(v.isdigit()):
|
||||
new_standard.authority.add(User.objects.get(pk=v))
|
||||
|
||||
# EXECUTORS
|
||||
ex = normalForm.cleaned_data['us_ex'].split(",")
|
||||
for v in ex:
|
||||
if(v.isdigit()):
|
||||
new_standard.executor.add(User.objects.get(pk=v))
|
||||
|
||||
# AUTHORITY
|
||||
ver = normalForm.cleaned_data['us_ver'].split(",")
|
||||
for v in ver:
|
||||
if(v.isdigit()):
|
||||
new_standard.representative.add(User.objects.get(pk=v))
|
||||
|
||||
# ADD GROUPS
|
||||
groups = normalForm.cleaned_data['checked_groups'].split(",")
|
||||
|
||||
for g in groups:
|
||||
if(g.isdigit()):
|
||||
new_standard.visibleby.add(AgencyGroup.objects.get(pk=g))
|
||||
|
||||
# ADD STANDARDS
|
||||
standards = normalForm.cleaned_data['added_standards'].split(",")
|
||||
for s in standards:
|
||||
if(s.isdigit()):
|
||||
new_standard.linked_standards.add(Standards.objects.get(pk=s))
|
||||
|
||||
# ADD FILES
|
||||
files = normalForm.cleaned_data['added_files'].split(",")
|
||||
for f in files:
|
||||
if(f.isdigit()):
|
||||
new_standard.addedfiles.add(DataFile.objects.get(pk=f))
|
||||
|
||||
# ADD QUICKLINKS
|
||||
quicklinks = normalForm.cleaned_data['added_quicklinks'].split(",")
|
||||
for f in quicklinks:
|
||||
if(f.isdigit()):
|
||||
new_standard.addedquicklinks.add(QuickLinks.objects.get(pk=f))
|
||||
|
||||
# ADD PASSWORDS
|
||||
addedpasswords = normalForm.cleaned_data['added_passwords'].split(",")
|
||||
for f in addedpasswords:
|
||||
if(f.isdigit()):
|
||||
new_standard.addedpasswords.add(AGPassword.objects.get(pk=f))
|
||||
|
||||
# ADD CONTACTS
|
||||
contacts = normalForm.cleaned_data['added_contacts'].split(",")
|
||||
for f in contacts:
|
||||
if(f.isdigit()):
|
||||
new_standard.addedcontacts.add(AGContacts.objects.get(pk=f))
|
||||
|
||||
|
||||
tempstandardname = normalForm.cleaned_data['name']
|
||||
if(new_standard.public and request.user.has_perm('users.standardmanager')):
|
||||
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:
|
||||
normalForm = StandardAddStandard(instance=request.user)
|
||||
editorForm = StandardAddStandardEditor(instance=request.user)
|
||||
|
||||
|
||||
possibleFilesByVisible = []
|
||||
|
||||
allfiles = DataFile.objects.filter(agency=request.user.profile.agency)
|
||||
|
||||
for f in allfiles:
|
||||
actParent = DataDir.objects.get(pk=f.parent.pk)
|
||||
if actParent.is_root:
|
||||
possibleFilesByVisible.append(f)
|
||||
else:
|
||||
if(checkUserDirRights(request, actParent, request.user.pk)):
|
||||
possibleFilesByVisible.append(f)
|
||||
|
||||
context = {
|
||||
'normalForm' : normalForm,
|
||||
'editorForm' : editorForm,
|
||||
'active_link' : 'standards',
|
||||
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency),
|
||||
'usersofagency' : User.objects.filter(profile__agency=request.user.profile.agency),
|
||||
'files' : possibleFilesByVisible,
|
||||
'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk,
|
||||
'standards' : Standards.objects.filter(agency=request.user.profile.agency, public=True),
|
||||
'quicklinks' : QuickLinks.objects.filter(agency=request.user.profile.agency),
|
||||
'contacts' : AGContacts.objects.filter(agency=request.user.profile.agency),
|
||||
'passwords' : AGPassword.objects.filter(agency=request.user.profile.agency),
|
||||
}
|
||||
return render(request, 'standards/standards_add.html', context)
|
||||
context = {
|
||||
'normalForm' : normalForm,
|
||||
'editorForm' : editorForm,
|
||||
'standard' : standard,
|
||||
'files' : possibleFilesByVisible,
|
||||
'standard_possible' : possible_standards,
|
||||
'poss_verant' : possible_verant_final,
|
||||
'poss_ex' : possible_ex_final,
|
||||
'poss_ver' : possible_ver_final,
|
||||
'possible_quicklinks' : possible_quicklinks,
|
||||
'possible_passwords' : possible_passwords,
|
||||
'possible_contacts' : possible_contacts,
|
||||
'agencynetworks' : agencynetworks,
|
||||
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency),
|
||||
'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk,
|
||||
'active_link' : 'standards',
|
||||
'update' : True
|
||||
}
|
||||
return render(request, 'standards/standards_add.html', context)
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from standards.models import StandardCommentRate, StandardComments
|
|||
from django.contrib.auth.models import Permission
|
||||
from message.models import Message
|
||||
from cloud.models import DataFile
|
||||
from organizer.models import AGContacts
|
||||
|
||||
|
||||
admin.site.register(StandardComments)
|
||||
|
|
@ -17,6 +18,7 @@ admin.site.register(AgencyJob)
|
|||
admin.site.register(Prio)
|
||||
admin.site.register(Message)
|
||||
admin.site.register(AgencyNetwork)
|
||||
admin.site.register(AGContacts)
|
||||
admin.site.register(AgencyNetworkPreperation)
|
||||
admin.site.register(DataFile)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue