0.8.2. Zwischencommit Standards fertig

This commit is contained in:
holger.trampe 2020-03-24 23:12:26 +01:00
parent 06315cc953
commit 782896691c
11 changed files with 626 additions and 101 deletions

View File

@ -383,11 +383,9 @@ def SettingsAjaxRouter(request):
# GET POSSIBLE TO ADD USERS # GET POSSIBLE TO ADD USERS
k = 0 k = 0
possible_users = User.objects.filter(profile__agency__pk=request.user.profile.agency.pk).exclude(pk__in=added_users) possible_users = User.objects.filter(profile__agency__pk=request.user.profile.agency.pk).exclude(pk__in=added_users)
print(possible_users)
for us in possible_users: for us in possible_users:
posus.update({ k : {"fullname" : us.first_name + " " + us.last_name, "userid" : us.pk}}) posus.update({ k : {"fullname" : us.first_name + " " + us.last_name, "userid" : us.pk}})
k += 1 k += 1
print(posus)
data = {"taskname" : task.name, "visible" : task.visible, "added_users" : addus, "addedl" : i, "possl" : k, "possible_users" : posus, "taskarea" : task.area.pk} data = {"taskname" : task.name, "visible" : task.visible, "added_users" : addus, "addedl" : i, "possl" : k, "possible_users" : posus, "taskarea" : task.area.pk}
success = True success = True
# REMOVE Task # REMOVE Task

View File

@ -22,11 +22,10 @@ class StandardAddStandard(forms.ModelForm):
"task" : "Tätigkeitsbereich", "task" : "Tätigkeitsbereich",
"content": "Inhalt", "content": "Inhalt",
"public" : "Direkt veröffentlichen?", "public" : "Direkt veröffentlichen?",
"representative" : "Vertreter", "freefield_title" : "Freifeld Titel",
"executor" : "Ausführender", "freefield_content" : "Freifeld Inhalt",
"authority" : "Verantwortlicher",
} }
fields = ['name', 'area', 'task', 'content', 'public', "authority", "executor", "representative"] fields = ['name', 'area', 'task', 'content', 'public',"freefield_title", "freefield_content"]
''' '''
@ -51,14 +50,22 @@ class StandardAddStandard(forms.ModelForm):
elif self.instance.pk: elif self.instance.pk:
self.fields['task'].queryset = Tasks.objects.none() self.fields['task'].queryset = Tasks.objects.none()
self.fields['representative'].queryset = UserFullName.objects.filter(profile__agency__pk=kwargs['instance'].profile.agency.pk) self.fields['freefield_title'].required = False
self.fields['executor'].queryset = UserFullName.objects.filter(profile__agency__pk=kwargs['instance'].profile.agency.pk) self.fields['freefield_content'].required = False
self.fields['authority'].queryset = UserFullName.objects.filter(profile__agency__pk=kwargs['instance'].profile.agency.pk) self.fields['freefield_content'].widget.attrs['rows'] = 2
#self.fields['representative'].queryset = UserFullName.objects.filter(profile__agency__pk=kwargs['instance'].profile.agency.pk)
#self.fields['executor'].queryset = UserFullName.objects.filter(profile__agency__pk=kwargs['instance'].profile.agency.pk)
#self.fields['authority'].queryset = UserFullName.objects.filter(profile__agency__pk=kwargs['instance'].profile.agency.pk)
self.fields['checked_groups'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) 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_files'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput())
self.fields['added_standards'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) self.fields['added_standards'] = 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())
class StandardAddStandardEditor(forms.ModelForm): class StandardAddStandardEditor(forms.ModelForm):
@ -84,11 +91,10 @@ class StandardUpdateStandard(forms.ModelForm):
"area" : "Übergeordneter Bereich", "area" : "Übergeordneter Bereich",
"task" : "Tätigkeitsbereich", "task" : "Tätigkeitsbereich",
"content": "Inhalt", "content": "Inhalt",
"representative" : "Vertreter", "freefield_title" : "Freifeld Titel",
"executor" : "Ausführender", "freefield_content" : "Freifeld Inhalt",
"authority" : "Verantwortlicher",
} }
fields = ['name', 'area', 'task', 'content', "authority", "executor", "representative"] fields = ['name', 'area', 'task', 'content',"freefield_title", "freefield_content"]
''' '''
Hier werden die Elemente für die DropDowns erstellt, damit Hier werden die Elemente für die DropDowns erstellt, damit
@ -115,9 +121,13 @@ class StandardUpdateStandard(forms.ModelForm):
elif loggeduser.pk: elif loggeduser.pk:
self.fields['task'].queryset = Tasks.objects.filter(area__pk=standard.area.pk) self.fields['task'].queryset = Tasks.objects.filter(area__pk=standard.area.pk)
self.fields['representative'].queryset = UserFullName.objects.filter(profile__agency__pk=loggeduser.profile.agency.pk)
self.fields['executor'].queryset = UserFullName.objects.filter(profile__agency__pk=loggeduser.profile.agency.pk) self.fields['freefield_title'].required = False
self.fields['authority'].queryset = UserFullName.objects.filter(profile__agency__pk=loggeduser.profile.agency.pk) self.fields['freefield_content'].required = False
self.fields['freefield_content'].widget.attrs['rows'] = 2
#self.fields['representative'].queryset = UserFullName.objects.filter(profile__agency__pk=loggeduser.profile.agency.pk)
#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)
class StandardUpdateStandardEditor(forms.ModelForm): class StandardUpdateStandardEditor(forms.ModelForm):

View File

@ -29,6 +29,9 @@ class Standards(models.Model):
public = models.BooleanField(default=False) public = models.BooleanField(default=False)
freefield_title = models.CharField(max_length=200, blank=False, default="")
freefield_content = models.TextField(max_length=500, blank=False, default="")
# USER # USER
# VERTRETER # VERTRETER

View File

@ -9,17 +9,26 @@
{% csrf_token %} {% csrf_token %}
<div class="row"><div class="col-8"> <div class="row"><div class="col-8">
{% for field in normalForm %} {% for field in normalForm %}
{% if field.is_hidden == False %}
{% if forloop.counter|divisibleby:6 %} {% if forloop.counter|divisibleby:6 %}
</div><div class="col-3"> </div><div class="col-3">
{{field|as_crispy_field }} {{field|as_crispy_field }}
{% else %} {% else %}
{{field|as_crispy_field }} {{field|as_crispy_field }}
{% endif %} {% endif %}
{% endif %}
{% endfor %} {% endfor %}
{% for field in normalForm %}
{% if field.is_hidden %}
{{field}}
{% endif %}
{% endfor %}
<button type="button" class="btn btn-primary mb-2" onclick="javascript:changeAddedUsers()">Mitarbeiter zuweisen</button>
<!-- COLLAPSE AREA FOR GROUPS FILES AND LINKED STANDARDS --> <!-- COLLAPSE AREA FOR GROUPS FILES AND LINKED STANDARDS -->
<div class="accordion" style="margin-top: 47px" id="additionalStandardInfos"> <div class="accordion" id="additionalStandardInfos">
<div class="card"> <div class="card">
<div class="card-header" id="st_groups"> <div class="card-header" id="st_groups">
<h5 class="mb-0"> <h5 class="mb-0">
@ -105,23 +114,6 @@
</div> </div>
</div> </div>
</div> </div>
<!--
<div class="card">
<div class="card-header" id="st_indi">
<h5 class="mb-0">
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#stindi_content" aria-expanded="false" aria-controls="stindi_content">
Freies Feld&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Bearbeiten Sie hier ein individuelles Text- und Inhaltsfeld." class="far fa-question-circle"></i></small>
</button>
</h5>
</div>
<div id="stindi_content" class="collapse" aria-labelledby="st_groups" data-parent="#additionalStandardInfos">
<div class="card-body">
dd
</div>
</div>
</div>
-->
</div> </div>
</div></div> </div></div>
@ -172,10 +164,202 @@
</div> </div>
</div> </div>
<!-- Add Users to Standard -->
<div class="modal fade" id="addUsersToStandard" tabindex="-1" data-backdrop="static" aria-labelledby="" aria-hidden="true">
<div class="modal-dialog " role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Mitarbeiter zuweisen</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<!--
Verantwortlicher
Ausführender
Vertreter
-->
<h6>Verantwortlicher hinzufügen:</h6>
<div class="input-group mb-3">
<input class="form-control searchuserfieldstask" list="possusers_verant" id="searchuser_verant" type="text" onkeyup="javascript:checkUserVerant()" >
<div class="input-group-append">
<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 %}
</datalist>
</div>
<!--<h6>Verantwortliche Mitarbeiter:</h6>-->
<div id="added_users_verant_buttons"></div>
<hr>
<!--
Ausführender
Vertreter
-->
<h6>Ausführender hinzufügen:</h6>
<div class="input-group mb-3">
<input class="form-control searchuserfieldstask" list="possusers_ex" id="searchuser_ex" type="text" onkeyup="javascript:checkUserEx()" >
<div class="input-group-append">
<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 %}
</datalist>
</div>
<!--<h6>Ausführende Mitarbeiter:</h6>-->
<div id="added_users_ex_buttons"></div>
<hr>
<!--
Vertreter
-->
<h6>Vertreter hinzufügen:</h6>
<div class="input-group mb-3">
<input class="form-control searchuserfieldstask" list="possusers_ver" id="searchuser_ver" type="text" onkeyup="javascript:checkUserVer()" >
<div class="input-group-append">
<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 %}
</datalist>
</div>
<!--<h6>Vertretende Mitarbeiter:</h6>-->
<div id="added_users_ver_buttons"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" data-dismiss="modal">Fertig</button>
</div>
</div>
</div>
</div>
<script type="text/javascript"> <script type="text/javascript">
var ua = window.navigator.userAgent;
var isIE = /MSIE|Trident/.test(ua);
if ( isIE ) {
//IE specific code goes here
setInterval(function()
{
alluserfields = $(".searchuserfieldstask").each(function(key, value){
specific_userfield_id = value['id'].split("_")[1];
checkUserVerant();
checkUserEx();
checkUserVer();
});
},400);
}
//USERSTOSTANDARDS
//Verantwortlicher
act_verant = [];
function checkUserVerant(){
var g = $('#searchuser_verant').val();
var id = $('#possusers_verant').find('option[value="' + g + '"]').attr('id');
if(id != undefined && id.length > 0){
tempid = id.split("_")[0];
clearUserSearchFields("verant");
$("#added_users_verant_buttons").append('<span id="span_btn_verant_'+tempid+'" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromVeran('+tempid+', \''+g+'\')">'+g+'&nbsp;&nbsp;<i class="fas fa-times"></i></a ></span>');
$("#" + tempid + "_verant").remove();
act_verant.push(tempid);
$("#id_us_verant").val(act_verant);
}
}
function removeUserFromVeran(id, name){
index_to_rem = act_verant.indexOf(id.toString());
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();
}
//Ausführender
act_ex = [];
function checkUserEx(){
var g = $('#searchuser_ex').val();
var id = $('#possusers_ex').find('option[value="' + g + '"]').attr('id');
if(id != undefined && id.length > 0){
tempid = id.split("_")[0];
clearUserSearchFields("ex");
$("#added_users_ex_buttons").append('<span id="span_btn_ex_'+tempid+'" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromEx('+tempid+', \''+g+'\')">'+g+'&nbsp;&nbsp;<i class="fas fa-times"></i></a ></span>');
$("#" + 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);
$('#possusers_ex').append('<option id="'+id+'_ex" value="'+ name +'">'+ name +'</option>');
$("#id_us_ex").val(act_ex);
$("#span_btn_ex_" + id).remove();
}
//Vertreter
act_ver = [];
function checkUserVer(){
var g = $('#searchuser_ver').val();
var id = $('#possusers_ver').find('option[value="' + g + '"]').attr('id');
if(id != undefined && id.length > 0){
tempid = id.split("_")[0];
clearUserSearchFields("ver");
$("#added_users_ver_buttons").append('<span id="span_btn_ver_'+tempid+'" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromVer('+tempid+', \''+g+'\')">'+g+'&nbsp;&nbsp;<i class="fas fa-times"></i></a ></span>');
$("#" + tempid + "_ver").remove();
act_ver.push(tempid);
$("#id_us_ver").val(act_ver);
}
}
function removeUserFromVer(id, name){
index_to_rem = act_ver.indexOf(id.toString());
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();
}
//Clear user search fields
function clearUserSearchFields(opt){
$("#searchuser_" + opt).val("");
}
//STANDARDS //STANDARDS
actualStandards = []; actualStandards = [];
function changeAddedUsers(){
$("#addUsersToStandard").modal("toggle");
}
function clearSearchfieldAddStandard(){ function clearSearchfieldAddStandard(){
$("#searchstandards").val(""); $("#searchstandards").val("");
} }
@ -268,8 +452,7 @@ function uploadAction(filetodo){
} }
else{ else{
$("#forbiddenFileType").modal("toggle") $("#forbiddenFileType").modal("toggle")
} }
} }
}); });
} }

View File

@ -9,49 +9,24 @@
<li class="breadcrumb-item active" aria-current="page"><a href="{% url 'standard-task' standard.task.pk %}">{{standard.task.name}}</a></li> <li class="breadcrumb-item active" aria-current="page"><a href="{% url 'standard-task' standard.task.pk %}">{{standard.task.name}}</a></li>
</ol> </ol>
</nav> </nav>
<small>
<h2>{{standard.name}}</h2>
Erstellt durch <a href="{% url 'orga-single' standard.created_standard_by.pk %}">{{standard.created_standard_by.first_name}} {{standard.created_standard_by.last_name}}</a> am {{standard.created_standard_date}} | Zuletzt bearbeitet von <a href="{% url 'orga-single' standard.last_modified_by.pk %}">{{ standard.last_modified_by.first_name}} {{ standard.last_modified_by.last_name}}</a> am {{ standard.last_modified_on}}
{% if standard.created_standard_by == user or perms.users.standard_management %}
&nbsp;|&nbsp;<a href="{% url 'standard-delete' standard.pk %}">Löschen</a>
&nbsp;|&nbsp;<a href="{% url 'standard-update' standard.pk %}">Bearbeiten</a>
{% endif%}
</small>
<small> <br />
{% if standard.authority.count > 0 %}
Verantwortliche:&nbsp;
{% for u in standard.authority.all %}
<a href="{% url 'orga-single' u.pk%}"> {{u.first_name}} {{u.last_name}}</a>&nbsp;|&nbsp;
{% endfor %}
<br />
{% endif %}
{% if standard.executor.count > 0 %} <h2>{{standard.name}}
Ausführende Personen:&nbsp;
{% for u in standard.executor.all %}
<a href="{% url 'orga-single' u.pk%}"> {{u.first_name}} {{u.last_name}}</a>&nbsp;|&nbsp;
{% endfor %}
<br />
{% endif %}
{% if standard.representative.count > 0 %} <span style="float: right">
Vertreter:&nbsp; {% if standard.created_standard_by == user or perms.users.standard_management %}
{% for u in standard.representative.all %} <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 href="{% url 'orga-single' u.pk%}"> {{u.first_name}} {{u.last_name}}</a>&nbsp;|&nbsp; <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>
{% endfor %} {% endif %}
<br /> </span>
{% endif %} </h2>
</small>
<hr> <hr>
<div class="row col"> <div class="row col">
{% if standard.addedfiles.all|length == 0 and standard.linked_standards.all|length == 0 %} {% if standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.authority.count > 0 or standard.executor.count > 0 or standard.representative.count > 0 or standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.freefield_title|length > 0 %}
<div class="card col-12" style="min-height: 500px">
{% else %}
<div class="card col-9" style="min-height: 500px"> <div class="card col-9" style="min-height: 500px">
{% else %}
<div class="card col-12" style="min-height: 500px">
{% endif %} {% endif %}
<div class="card-body"> <div class="card-body">
<h5 class="card-title"></h5> <h5 class="card-title"></h5>
@ -61,15 +36,71 @@
</p> </p>
</div> </div>
</div> </div>
<!-- FILES -->
<!-- PERSONEN -->
{% if standard.authority.count > 0 or standard.executor.count > 0 or standard.representative.count > 0 or standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.freefield_title|length > 0 %}
<div class="col-3"> <div class="col-3">
{% if standard.freefield_title|length > 0 %}
<div class="card col-14 ml-1 mb-2" style="">
<div class="card-body">
<h5 class="card-title">{{standard.freefield_title}}</h5>
<p class="card-text">
{{standard.freefield_content}}
</p>
</div>
</div>
{% endif %}
{% 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-body">
<h5 class="card-title">Personen</h5>
<p class="card-text">
{% if standard.authority.count > 0 %}
Verantwortlich: <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%}&nbsp;|&nbsp;{% endif %}
{% endfor %}
<br />
{% endif %}
{% if standard.executor.count > 0 %}
Ausführende:<br />
{% for u in standard.executor.all %}
<a href="{% url 'orga-single' u.pk%}"> {{u.first_name}} {{u.last_name}}</a>{% if forloop.counter < standard.executor.count%}&nbsp;|&nbsp;{% endif %}
{% endfor %}
<br />
{% endif %}
{% if standard.representative.count > 0 %}
Vertreter:<br />
{% for u in standard.representative.all %}
<a href="{% url 'orga-single' u.pk%}"> {{u.first_name}} {{u.last_name}}</a>{% if forloop.counter < standard.representative.count%}&nbsp;|&nbsp;{% endif %}
{% endfor %}
<br />
{% endif %}
</p>
</div>
</div>
{% endif %}
<!-- FILES -->
{% if standard.addedfiles.all|length > 0 %} {% if standard.addedfiles.all|length > 0 %}
<div class="card col-14 ml-2 mb-3" style=""> <div class="card col-14 ml-1 mb-2" style="">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">Dateien</h5> <h5 class="card-title">Dateien</h5>
<p class="card-text"> <p class="card-text">
{% for files in standard.addedfiles.all %} {% for files in standard.addedfiles.all %}
<a href="{{files.file.url}}" download>{{files.name|truncatechars:30}}</a><br /> <a href="{% url 'cloud-td' files.pk %}" target="_blank">{{files.name|truncatechars:30}}</a><br />
{% endfor %} {% endfor %}
</p> </p>
</div> </div>
@ -77,7 +108,7 @@
{% endif %} {% endif %}
<!-- STANDARDS --> <!-- STANDARDS -->
{% if standard.linked_standards.all|length > 0 %} {% if standard.linked_standards.all|length > 0 %}
<div class="card col-14 ml-2" style=""> <div class="card col-14 ml-1" style="">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">Verwandte Standards</h5> <h5 class="card-title">Verwandte Standards</h5>
<p class="card-text"> <p class="card-text">
@ -109,6 +140,12 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% endif %}
</div> </div>
<div class="mt-2">
<small>
Erstellt durch <a href="{% url 'orga-single' standard.created_standard_by.pk %}">{{standard.created_standard_by.first_name}} {{standard.created_standard_by.last_name}}</a> am {{standard.created_standard_date}} | Zuletzt bearbeitet von <a href="{% url 'orga-single' standard.last_modified_by.pk %}">{{ standard.last_modified_by.first_name}} {{ standard.last_modified_by.last_name}}</a> am {{ standard.last_modified_on}}
</small>
</div>
</div> </div>
{% endblock content %} {% endblock content %}

View File

@ -6,20 +6,21 @@
<h3>Standard bearbeiten{% if request.user.profile.showtooltips %}&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Aktualisieren Sie hier die Informationen des Standards." class="far fa-question-circle"></i></small>{% endif %}</h3> <h3>Standard bearbeiten{% if request.user.profile.showtooltips %}&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Aktualisieren Sie hier die Informationen des Standards." class="far fa-question-circle"></i></small>{% endif %}</h3>
<hr> <hr>
<form method="POST" id="taskareaform"> <form method="POST" id="taskareaform">
{% csrf_token %} {% csrf_token %}
<div class="row"><div class="col-8"> <div class="row"><div class="col-8">
{% for field in normalForm %} {% for field in normalForm %}
{% if forloop.counter|divisibleby:5 %} {% if forloop.counter|divisibleby:5 %}
</div><div class="col-3"> </div><div class="col-3">
{{field|as_crispy_field }} {{field|as_crispy_field }}
{% else %} {% else %}
{{field|as_crispy_field }} {{field|as_crispy_field }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<button type="button" class="btn btn-primary mb-2" onclick="javascript:showUpdateUsersStandard()">Zugewiesene Mitarbeiter</button>
<!-- COLLAPSE AREA FOR GROUPS FILES AND LINKED STANDARDS --> <!-- COLLAPSE AREA FOR GROUPS FILES AND LINKED STANDARDS -->
<div class="accordion" style="margin-top: 47px" id="additionalStandardInfos"> <div class="accordion" id="additionalStandardInfos">
<div class="card"> <div class="card">
<div class="card-header" id="st_groups"> <div class="card-header" id="st_groups">
<h5 class="mb-0"> <h5 class="mb-0">
@ -44,6 +45,7 @@
</div> </div>
</div> </div>
</div> </div>
{% if request.user.profile.agency.module_files %} {% if request.user.profile.agency.module_files %}
<div class="card"> <div class="card">
<div class="card-header" id="st_files"> <div class="card-header" id="st_files">
@ -120,8 +122,8 @@
</div> </div>
<p>Wenn ein Standard bearbeitet wurde, kann er nur von einer Person mit dem Recht <i>Standards bearbeiten und freischalten</i> wieder veröffentlicht werden. Ein Standard wird nach Bearbeitung als <i>Nicht veröffentlicht</i> gesetzt.</p> <p>Wenn ein Standard bearbeitet wurde, kann er nur von einer Person mit dem Recht <i>Standards bearbeiten und freischalten</i> wieder veröffentlicht werden. Ein Standard wird nach Bearbeitung als <i>Nicht veröffentlicht</i> gesetzt.</p>
<hr> <hr>
<button type="submit" class="btn btn-success" href="{% url 'standard-update' standard_id %} ">Aktualisieren</button>&nbsp; <button type="submit" class="btn btn-success" href="{% url 'standard-update' standard_id %} ">Aktualisieren</button>&nbsp;
{% if perms.users.standard_management %} {% if perms.users.standard_management %}
{% if standard_status == False %} {% if standard_status == False %}
@ -130,7 +132,7 @@
<a class="btn btn-warning" href="{% url 'standard-status' standard_id %} ">Veröffentlichung aufheben</a>&nbsp; <a class="btn btn-warning" href="{% url 'standard-status' standard_id %} ">Veröffentlichung aufheben</a>&nbsp;
{% endif %} {% endif %}
{% endif %} {% endif %}
<a class="btn" href="{% url 'standards' %} ">Abbrechen</a> <a class="btn" href="{% url 'standards' %} ">Abbrechen</a>
</form> </form>
</div> </div>
@ -154,7 +156,243 @@
</div> </div>
</div> </div>
<!-- Add Users to Standard -->
<div class="modal fade" id="changeUsersToStandard" tabindex="-1" data-backdrop="static" aria-labelledby="" aria-hidden="true">
<div class="modal-dialog " role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Mitarbeiter zuweisen</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<!--
Verantwortlicher
Ausführender
Vertreter
-->
<h6>Verantwortlicher hinzufügen:</h6>
<div class="input-group mb-3">
<input class="form-control searchuserfieldstask" list="possusers_verant" id="searchuser_verant" type="text" onkeyup="javascript:checkUserVerant()" >
<div class="input-group-append">
<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 poss_verant %}
<option id="{{us.pk}}_verant" value="{{us.first_name}} {{us.last_name}}"></option>
{% endfor %}
</datalist>
</div>
<h6>Verantwortliche Mitarbeiter:</h6>
<div id="added_users_verant_buttons">
{% for us in standard.authority.all %}
<span id="span_btn_verant_{{us.pk}}" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromVerant({{us.pk}}, '{{us.first_name}} {{us.last_name}}')">{{us.first_name}} {{us.last_name}}&nbsp;&nbsp;<i class="fas fa-times"></i></a ></span>
{% endfor %}
</div>
<hr>
<!--
Ausführender
Vertreter
-->
<h6>Ausführende hinzufügen:</h6>
<div class="input-group mb-3">
<input class="form-control searchuserfieldstask" list="possusers_ex" id="searchuser_ex" type="text" onkeyup="javascript:checkUserEx()" >
<div class="input-group-append">
<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 poss_ex %}
<option id="{{us.pk}}_ex" value="{{us.first_name}} {{us.last_name}}"></option>
{% endfor %}
</datalist>
</div>
<h6>Ausführende Mitarbeiter:</h6>
<div id="added_users_ex_buttons"></div>
{% for us in standard.executor.all %}
<span id="span_btn_ex_{{us.pk}}" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromEx({{us.pk}}, '{{us.first_name}} {{us.last_name}}')">{{us.first_name}} {{us.last_name}}&nbsp;&nbsp;<i class="fas fa-times"></i></a ></span>
{% endfor %}
<hr>
<!--
Vertreter
-->
<h6>Vertreter hinzufügen:</h6>
<div class="input-group mb-3">
<input class="form-control searchuserfieldstask" list="possusers_ver" id="searchuser_ver" type="text" onkeyup="javascript:checkUserVer()" >
<div class="input-group-append">
<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 poss_ver %}
<option id="{{us.pk}}_ver" value="{{us.first_name}} {{us.last_name}}"></option>
{% endfor %}
</datalist>
</div>
<h6>Vertretende Mitarbeiter:</h6>
<div id="added_users_ver_buttons"></div>
{% for us in standard.representative.all %}
<span id="span_btn_ver_{{us.pk}}" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromVer({{us.pk}}, '{{us.first_name}} {{us.last_name}}')">{{us.first_name}} {{us.last_name}}&nbsp;&nbsp;<i class="fas fa-times"></i></a ></span>
{% endfor %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" data-dismiss="modal">Fertig</button>
</div>
</div>
</div>
</div>
<script type="text/javascript"> <script type="text/javascript">
var ua = window.navigator.userAgent;
var isIE = /MSIE|Trident/.test(ua);
if ( isIE ) {
//IE specific code goes here
setInterval(function()
{
alluserfields = $(".searchuserfieldstask").each(function(key, value){
specific_userfield_id = value['id'].split("_")[1];
checkUserVerant();
checkUserEx();
checkUserVer();
});
},400);
}
//USERSTANDARD
var tempuserid = "";
var tempusername = "";
function showUpdateUsersStandard(){
$("#changeUsersToStandard").modal("toggle");
}
function checkUserVerant(){
var g = $('#searchuser_verant').val();
var id = $('#possusers_verant').find('option[value="' + g + '"]').attr('id');
if(id != undefined && id.length > 0){
tempid = id.split("_")[0];
tempuserid = tempid;
clearUserSearchFields("verant");
$("#" + tempid + "_verant").remove();
$.ajax({
url: "{% url 'update_standard_by_ajax' standard.pk %}",
data: {
action : 's_addverant',
userid : tempid
},
success: function (data) {
$("#added_users_verant_buttons").append('<span id="span_btn_verant_'+tempuserid+'" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromVerant('+tempuserid+', \''+g+'\')">'+g+'&nbsp;&nbsp;<i class="fas fa-times"></i></a ></span>');
}
});
}
}
function removeUserFromVerant(id, name){
$('#possusers_verant').append('<option id="'+id+'_verant" value="'+ name +'">'+ name +'</option>');
$("#span_btn_verant_" + id).remove();
$.ajax({
url: "{% url 'update_standard_by_ajax' standard.pk %}",
data: {
action : 's_remverant',
userid : id
},
success: function (data) {}
});
}
function checkUserEx(){
var g = $('#searchuser_ex').val();
var id = $('#possusers_ex').find('option[value="' + g + '"]').attr('id');
if(id != undefined && id.length > 0){
tempid = id.split("_")[0];
tempuserid = tempid;
clearUserSearchFields("ex");
$("#" + tempid + "_ex").remove();
$.ajax({
url: "{% url 'update_standard_by_ajax' standard.pk %}",
data: {
action : 's_addex',
userid : tempid
},
success: function (data) {
$("#added_users_ex_buttons").append('<span id="span_btn_ex_'+tempuserid+'" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromEx('+tempuserid+', \''+g+'\')">'+g+'&nbsp;&nbsp;<i class="fas fa-times"></i></a ></span>');
}
});
}
}
function removeUserFromEx(id, name){
$('#possusers_ex').append('<option id="'+id+'_ex" value="'+ name +'">'+ name +'</option>');
$("#span_btn_ex_" + id).remove();
$.ajax({
url: "{% url 'update_standard_by_ajax' standard.pk %}",
data: {
action : 's_remex',
userid : id
},
success: function (data) {}
});
}
function checkUserVer(){
var g = $('#searchuser_ver').val();
var id = $('#possusers_ver').find('option[value="' + g + '"]').attr('id');
if(id != undefined && id.length > 0){
tempid = id.split("_")[0];
tempuserid = tempid;
clearUserSearchFields("ver");
$("#" + tempid + "_ver").remove();
$.ajax({
url: "{% url 'update_standard_by_ajax' standard.pk %}",
data: {
action : 's_addver',
userid : tempid
},
success: function (data) {
$("#added_users_ver_buttons").append('<span id="span_btn_ver_'+tempuserid+'" class="badge badge-pill badge-primary mr-2 mt-2"><a class="btn btn-primary" onclick="javascript:removeUserFromVer('+tempuserid+', \''+g+'\')">'+g+'&nbsp;&nbsp;<i class="fas fa-times"></i></a ></span>');
}
});
}
}
function removeUserFromVer(id, name){
$('#possusers_ver').append('<option id="'+id+'_ver" value="'+ name +'">'+ name +'</option>');
$("#span_btn_ver_" + id).remove();
$.ajax({
url: "{% url 'update_standard_by_ajax' standard.pk %}",
data: {
action : 's_remver',
userid : id
},
success: function (data) {}
});
}
//Clear user search fields
function clearUserSearchFields(opt){
$("#searchuser_" + opt).val("");
}
//STANDARD //STANDARD
function clearSearchfieldAddStandard(){ function clearSearchfieldAddStandard(){
$("#searchstandards").val(""); $("#searchstandards").val("");

View File

@ -32,7 +32,6 @@ class StandardsManagement(LoginRequiredMixin, ListView):
standardcontent = [] standardcontent = []
for a in areas: for a in areas:
print(a)
standardcontent.append({"area" : a, "tasks" : []}) standardcontent.append({"area" : a, "tasks" : []})
tasks_in_area = Tasks.objects.filter(agency__pk=self.request.user.profile.agency.pk, area__pk=a.pk).order_by("name") tasks_in_area = Tasks.objects.filter(agency__pk=self.request.user.profile.agency.pk, area__pk=a.pk).order_by("name")
@ -107,14 +106,33 @@ def StandardAdd(request):
new_standard.content = editorForm.cleaned_data['content'] new_standard.content = editorForm.cleaned_data['content']
new_standard.public = normalForm.cleaned_data['public'] 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']
# GROUPS # GROUPS
new_standard.save() new_standard.save()
new_standard.representative.set(normalForm.cleaned_data['representative']) #new_standard.representative.set(normalForm.cleaned_data['representative'])
new_standard.executor.set(normalForm.cleaned_data['executor']) #new_standard.executor.set(normalForm.cleaned_data['executor'])
new_standard.authority.set(normalForm.cleaned_data['authority']) #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 # ADD GROUPS
groups = normalForm.cleaned_data['checked_groups'].split(",") groups = normalForm.cleaned_data['checked_groups'].split(",")
@ -162,14 +180,13 @@ def StandardAdd(request):
else: else:
if(checkUserDirRights(request, actParent, request.user.pk)): if(checkUserDirRights(request, actParent, request.user.pk)):
possibleFilesByVisible.append(f) possibleFilesByVisible.append(f)
context = { context = {
'normalForm' : normalForm, 'normalForm' : normalForm,
'editorForm' : editorForm, 'editorForm' : editorForm,
'active_link' : 'standards', 'active_link' : 'standards',
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency), 'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency),
'usersofagency' : User.objects.filter(profile__agency=request.user.profile.agency),
'files' : possibleFilesByVisible, 'files' : possibleFilesByVisible,
'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk, '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) 'standards' : Standards.objects.filter(agency=request.user.profile.agency, public=True)
@ -193,10 +210,12 @@ def StandardUpdate(request, id):
existing_standard.area = normalForm.cleaned_data['area'] existing_standard.area = normalForm.cleaned_data['area']
existing_standard.name = normalForm.cleaned_data['name'] existing_standard.name = normalForm.cleaned_data['name']
existing_standard.content = editorForm.cleaned_data['content'] existing_standard.content = editorForm.cleaned_data['content']
existing_standard.freefield_content = normalForm.cleaned_data['freefield_content']
existing_standard.freefield_title = normalForm.cleaned_data['freefield_title']
existing_standard.representative.set(normalForm.cleaned_data['representative']) #existing_standard.representative.set(normalForm.cleaned_data['representative'])
existing_standard.executor.set(normalForm.cleaned_data['executor']) #existing_standard.executor.set(normalForm.cleaned_data['executor'])
existing_standard.authority.set(normalForm.cleaned_data['authority']) #existing_standard.authority.set(normalForm.cleaned_data['authority'])
''' '''
@ -219,7 +238,6 @@ def StandardUpdate(request, id):
return redirect('/standards') return redirect('/standards')
else: else:
#normalForm = StandardUpdateStandard(instance=standard)
normalForm = StandardUpdateStandard(instance=standard) normalForm = StandardUpdateStandard(instance=standard)
editorForm = StandardUpdateStandardEditor(instance=standard) editorForm = StandardUpdateStandardEditor(instance=standard)
@ -241,14 +259,31 @@ def StandardUpdate(request, id):
possibleFilesByVisible.append(f) possibleFilesByVisible.append(f)
possiblestandards = Standards.objects.filter(agency=request.user.profile.agency, public=True) possiblestandards = Standards.objects.filter(agency=request.user.profile.agency, public=True)
possiblestandards_final = [] possiblestandards_final = []
for s in possiblestandards: for s in possiblestandards:
if s not in standard.linked_standards.all(): if s not in standard.linked_standards.all():
possiblestandards_final.append(s) possiblestandards_final.append(s)
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)
context = { context = {
'normalForm' : normalForm, 'normalForm' : normalForm,
'editorForm' : editorForm, 'editorForm' : editorForm,
@ -259,6 +294,9 @@ def StandardUpdate(request, id):
'possibleFilesByVisible' : possibleFilesByVisible, 'possibleFilesByVisible' : possibleFilesByVisible,
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency), 'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency),
'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk, 'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk,
'poss_verant' : possible_verant_final,
'poss_ex' : possible_ex_final,
'poss_ver' : possible_ver_final,
'possiblestandards' : possiblestandards_final 'possiblestandards' : possiblestandards_final
} }
return render(request, 'standards/standards_update.html', context) return render(request, 'standards/standards_update.html', context)
@ -355,7 +393,7 @@ def StandardTask(request, pk):
} }
return render(request, 'standards/standard_task.html', context) return render(request, 'standards/standard_task.html', context)
# AJAX SHIT
@login_required @login_required
def updatesbyajax(request, pk): def updatesbyajax(request, pk):
if(request.method == "GET"): if(request.method == "GET"):
@ -382,8 +420,26 @@ def updatesbyajax(request, pk):
elif(request.GET["action"] == "s_remstandard"): elif(request.GET["action"] == "s_remstandard"):
workingstandard.linked_standards.remove(Standards.objects.get(pk=request.GET["standardid"], agency=request.user.profile.agency)) workingstandard.linked_standards.remove(Standards.objects.get(pk=request.GET["standardid"], agency=request.user.profile.agency))
# ADD # ADD
elif(request.GET["action"] == "s_addstandard"): elif(request.GET["action"] == "s_addstandard"):
workingstandard.linked_standards.add(Standards.objects.get(pk=request.GET["standardid"], agency=request.user.profile.agency)) workingstandard.linked_standards.add(Standards.objects.get(pk=request.GET["standardid"], agency=request.user.profile.agency))
# VERANTWORTLICHER / AUTHORITY
# REMOVE
elif(request.GET["action"] == "s_remverant"):
workingstandard.authority.remove(User.objects.get(pk=request.GET["userid"], profile__agency=request.user.profile.agency))
elif(request.GET["action"] == "s_addverant"):
workingstandard.authority.add(User.objects.get(pk=request.GET["userid"], profile__agency=request.user.profile.agency))
# ASUFÜRHENDER / EXECUTOR
# REMOVE
elif(request.GET["action"] == "s_remex"):
workingstandard.executor.remove(User.objects.get(pk=request.GET["userid"], profile__agency=request.user.profile.agency))
elif(request.GET["action"] == "s_addex"):
workingstandard.executor.add(User.objects.get(pk=request.GET["userid"], profile__agency=request.user.profile.agency))
# VERTRETER / REPRESENETATIVE
# REMOVE
elif(request.GET["action"] == "s_remver"):
workingstandard.representative.remove(User.objects.get(pk=request.GET["userid"], profile__agency=request.user.profile.agency))
elif(request.GET["action"] == "s_addver"):
workingstandard.representative.add(User.objects.get(pk=request.GET["userid"], profile__agency=request.user.profile.agency))
else: else:
success = False success = False