Neue globale Suche implementiert
This commit is contained in:
parent
c94d0a2f0f
commit
049cf1f183
|
|
@ -125,7 +125,7 @@
|
|||
}
|
||||
else{
|
||||
tempid = null;
|
||||
$("#addusertoareabtn").prop('disabled', true);
|
||||
$("#addusertoareabtn").prop("disabled", true);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -41,33 +41,42 @@ def singleorga(request, pk):
|
|||
VON GROß NACH KLEIN - SINNLOS
|
||||
prios = Prio.objects.filter(user__pk=pk).order_by('-prio')[::-1]
|
||||
'''
|
||||
prios = Prio.objects.filter(user__pk=pk).order_by('-prio')
|
||||
areas = list(Areas.objects.filter(agency__pk=request.user.profile.agency.pk).order_by('areaorder'))
|
||||
i = 0
|
||||
for area in areas:
|
||||
areas[i].hex = areas[i].color
|
||||
areas[i].color = list(webcolors.hex_to_rgb(areas[i].color))
|
||||
i += 1
|
||||
|
||||
'''
|
||||
|
||||
user_first_name = user.first_name
|
||||
user_last_name = user.last_name
|
||||
user_id = user.pk
|
||||
context = {
|
||||
'active_link' : 'orga',
|
||||
'areas' : areas,
|
||||
'user_first_name' : user_first_name,
|
||||
'user_last_name' : user_last_name,
|
||||
'user_id' : user_id,
|
||||
'prios' : prios,
|
||||
'mail' : user.email,
|
||||
'userfunc' : user.profile.get_func_display,
|
||||
'imageurl' : user.profile.get_photo_url,
|
||||
'compfunc' : user.profile.compfunc,
|
||||
'phoneland' : user.profile.phoneland,
|
||||
'phonemobile' : user.profile.phonemobile
|
||||
}
|
||||
return render(request, 'orga/orga_single.html', context)
|
||||
Wenn eingelogger Nutzer nicht die gleiche Agency-ID hat,
|
||||
gehts zum Dashboard
|
||||
|
||||
'''
|
||||
if(user.profile.agency.pk==request.user.profile.agency.pk):
|
||||
prios = Prio.objects.filter(user__pk=pk).order_by('-prio')
|
||||
areas = list(Areas.objects.filter(agency__pk=request.user.profile.agency.pk).order_by('areaorder'))
|
||||
i = 0
|
||||
for area in areas:
|
||||
areas[i].hex = areas[i].color
|
||||
areas[i].color = list(webcolors.hex_to_rgb(areas[i].color))
|
||||
i += 1
|
||||
|
||||
user_first_name = user.first_name
|
||||
user_last_name = user.last_name
|
||||
user_id = user.pk
|
||||
context = {
|
||||
'active_link' : 'orga',
|
||||
'areas' : areas,
|
||||
'user_first_name' : user_first_name,
|
||||
'user_last_name' : user_last_name,
|
||||
'user_id' : user_id,
|
||||
'prios' : prios,
|
||||
'mail' : user.email,
|
||||
'userfunc' : user.profile.get_func_display,
|
||||
'imageurl' : user.profile.get_photo_url,
|
||||
'compfunc' : user.profile.compfunc,
|
||||
'phoneland' : user.profile.phoneland,
|
||||
'phonemobile' : user.profile.phonemobile
|
||||
}
|
||||
return render(request, 'orga/orga_single.html', context)
|
||||
else:
|
||||
return redirect('users-dashboard')
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -197,17 +197,18 @@
|
|||
<!-- Topbar Search -->
|
||||
<form class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100 navbar-search">
|
||||
<div class="input-group">
|
||||
<input list="searchres" placeholder="Suche..." id="search_string" onchange="javascript:checkValueSearchStringGlobal()" onkeyup="javascript:startSearch(this.value)" class="form-control bg-light border-0 small" >
|
||||
<input list="searchres" placeholder="Suche..." id="search_string" onkeyup="javascript:startSearch(this.value)" class="form-control bg-light border-0 small" >
|
||||
<datalist id="searchres" >
|
||||
</datalist>
|
||||
|
||||
<!--
|
||||
<input type="text" onkeyup="javascript:startSearch(this.value)" class="form-control bg-light border-0 small" placeholder="Suche..." aria-label="Suche" aria-describedby="basic-addon2" id="searchfield">
|
||||
-->
|
||||
<!--<div class="input-group-append">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" type="button" onclick="javascript:clearSF()">
|
||||
<i class="fas fa-times fa-sm"></i>
|
||||
</button>-->
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
|
@ -262,6 +263,8 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<div id="searchcontent">
|
||||
</div>
|
||||
<div id="maincontent">
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
|
|
@ -320,6 +323,17 @@
|
|||
|
||||
<script type="text/javascript">
|
||||
|
||||
function clearSF(){
|
||||
$("#searchcontent").empty();
|
||||
$("#searchcontent").hide();
|
||||
$("#maincontent").show();
|
||||
$("#search_string").val("");
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#searchcontent").hide();
|
||||
})
|
||||
|
||||
function startSearch(searchstring){
|
||||
|
||||
if(searchstring.length > 2){
|
||||
|
|
@ -332,19 +346,18 @@
|
|||
},
|
||||
success: function( data )
|
||||
{
|
||||
$("#searchres").empty();
|
||||
for (var i = 0; i < data['standards'].length; i++)
|
||||
{
|
||||
id = data['standards'][i]['id'];
|
||||
name = data['standards'][i]['name'] + " | " + data['standards'][i]['content'];
|
||||
console.log(name);
|
||||
$("#searchres").append('<option id="'+id+'" value="'+name+'"></option>');
|
||||
}
|
||||
$("#maincontent").hide();
|
||||
$("#searchcontent").show();
|
||||
$("#searchcontent").html(data);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#searchcontent").empty();
|
||||
$("#searchcontent").hide();
|
||||
$("#maincontent").show();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//Check valid input and go to standard by click
|
||||
function checkValueSearchStringGlobal(){
|
||||
for(i = 0; i < document.getElementById("searchres").options.length; i++){
|
||||
|
|
@ -355,5 +368,5 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<div class="row" style="float: left;">
|
||||
|
||||
<div class="card d-block mb-2 mr-2 " style="width: 60%" >
|
||||
<div class="card d-block mb-3 mr-3 " style="width: 60%" >
|
||||
<div class="card-body" >
|
||||
<h5 class="card-title">News</h5>
|
||||
<table class="table">
|
||||
|
|
@ -30,14 +30,14 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card d-block mb-2" style="width: 35%">
|
||||
<div class="card d-block mb-3" style="width: 34.8%">
|
||||
<div class="card-body">
|
||||
<img width="100%" src="{{ request.user.profile.agency.get_photo_url }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card d-block mb-2" style="width: 96%">
|
||||
<div class="card d-block mb-3" style="width: 96%">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Neueste Standards</h5>
|
||||
<table class="table">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
<div class="content-section col-12">
|
||||
<h3>Suchergebnisse</h3>
|
||||
<hr>
|
||||
<h4>Standards</h4>
|
||||
{% if res_standard|length > 0 %}
|
||||
{% for s in res_standard %}
|
||||
<a href="{% url 'standard-single' s.pk %}"><b>{{s.name|striptags}}</b> | {{s.content|truncatechars:125|striptags}}</a><br /><br />
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>Keine Ergebnisse in Standards</p>
|
||||
{% endif %}
|
||||
|
||||
<hr>
|
||||
<h4>Bereiche</h4>
|
||||
{% if res_areas|length > 0 %}
|
||||
{% for s in res_areas %}
|
||||
<a href="{% url 'standard-area' s.pk %}"><b>{{s.name|striptags}}</b></a><br /><br />
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>Keine Ergebnisse in Bereichen</p>
|
||||
{% endif %}
|
||||
|
||||
<hr>
|
||||
<h4>Aufgaben</h4>
|
||||
{% if res_tasks|length > 0 %}
|
||||
{% for s in res_tasks %}
|
||||
<a href="{% url 'standard-task' s.pk %}"><b>{{s.name|striptags}}</b></a><br /><br />
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>Keine Ergebnisse in Aufgaben</p>
|
||||
{% endif %}
|
||||
|
||||
<hr>
|
||||
<h4>Personen</h4>
|
||||
{% if res_pers|length > 0 %}
|
||||
{% for s in res_pers %}
|
||||
<a href="{% url 'orga-single' s.pk %}"><b>{{s.first_name}} {{s.last_name}}</b></a><br /><br />
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>Keine Ergebnisse in Personen</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
@ -22,6 +22,8 @@ import json
|
|||
from PIL import Image
|
||||
from django.template.loader import render_to_string
|
||||
from django.contrib.auth.forms import PasswordResetForm
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
'''
|
||||
|
||||
DASHBOARD-View
|
||||
|
|
@ -399,8 +401,11 @@ def GlobalSearch(request):
|
|||
searchfor = request.GET['searchstring']
|
||||
results = {}
|
||||
ag = request.user.profile.agency.pk
|
||||
results = Standards.objects.filter(agency__pk=ag, public=True).filter(name__icontains=searchfor) | Standards.objects.filter(agency__pk=ag, public=True).filter(content__contains=searchfor) | Standards.objects.filter(agency__pk=ag, public=True).filter(area__name__icontains=searchfor) | Standards.objects.filter(agency__pk=ag, public=True).filter(task__name__icontains=searchfor) | Standards.objects.filter(agency__pk=ag, public=True).filter(created_standard_by__last_name__icontains=searchfor)|Standards.objects.filter(agency__pk=ag, public=True).filter(created_standard_by__first_name__icontains=searchfor)
|
||||
|
||||
res_standard = Standards.objects.filter(agency__pk=ag, public=True).filter(name__icontains=searchfor) | Standards.objects.filter(agency__pk=ag, public=True).filter(content__contains=searchfor) | Standards.objects.filter(agency__pk=ag, public=True).filter(area__name__icontains=searchfor) | Standards.objects.filter(agency__pk=ag, public=True).filter(task__name__icontains=searchfor) | Standards.objects.filter(agency__pk=ag, public=True).filter(created_standard_by__last_name__icontains=searchfor)|Standards.objects.filter(agency__pk=ag, public=True).filter(created_standard_by__first_name__icontains=searchfor)
|
||||
res_areas = Areas.objects.filter(agency__pk=ag).filter(name__icontains=searchfor)
|
||||
res_tasks = Tasks.objects.filter(agency__pk=ag).filter(name__icontains=searchfor) |Tasks.objects.filter(agency__pk=ag).filter(area__name__icontains=searchfor)
|
||||
res_pers = User.objects.filter(profile__agency__pk=ag).filter(first_name__icontains=searchfor) | User.objects.filter(profile__agency__pk=ag).filter(last_name__icontains=searchfor)
|
||||
'''
|
||||
results_st = list(results)
|
||||
final_results_st = []
|
||||
i = 0
|
||||
|
|
@ -418,8 +423,10 @@ def GlobalSearch(request):
|
|||
tempele['last_modified_on'] = formats.date_format(ele.last_modified_on, "d.m.Y")
|
||||
final_results_st.append(tempele)
|
||||
i += 1
|
||||
|
||||
return JsonResponse({'standards' : final_results_st})
|
||||
'''
|
||||
#return JsonResponse({'standards' : final_results_st})
|
||||
html = render_to_string('users/searchres.html', {'res_standard': res_standard, 'res_areas': res_areas, 'res_tasks': res_tasks, 'res_pers': res_pers})
|
||||
return HttpResponse(html)
|
||||
else:
|
||||
return HttpResponse("Request method is not a GET")
|
||||
|
||||
|
|
@ -430,10 +437,8 @@ def searchStandardRouter(request):
|
|||
else:
|
||||
return redirect('dashboard')
|
||||
|
||||
|
||||
def UsersAreaTaskUpdate(request, pk):
|
||||
|
||||
|
||||
user = User.objects.get(pk=pk)
|
||||
if request.user.profile.agency.pk != user.profile.agency.pk:
|
||||
return redirect('dashboard')
|
||||
|
|
@ -481,8 +486,6 @@ def UsersAreaTaskUpdate(request, pk):
|
|||
task.usersfield.remove(user)
|
||||
Prio.objects.filter(user__pk=pk).filter(task__pk=task.pk).delete()
|
||||
task.save()
|
||||
|
||||
|
||||
username_message = user.first_name + " " + user.last_name
|
||||
messages.success(request, f'Zuständigkeiten für {username_message} aktualisiert!')
|
||||
return redirect('users-management')
|
||||
|
|
|
|||
Loading…
Reference in New Issue