Import vorbereiten
This commit is contained in:
parent
f5db4926ee
commit
abb0a329a5
|
|
@ -97,6 +97,16 @@
|
|||
<span>Agenturen</span></a>
|
||||
</li>
|
||||
|
||||
{% if active_link == 'adm-import' %}
|
||||
<li class="nav-item active">
|
||||
{% else %}
|
||||
<li class="nav-item">
|
||||
{%endif%}
|
||||
<a class="nav-link" href="{% url 'adm-import' %}">
|
||||
<i class="fas fa-file-invoice-dollar"></i>
|
||||
<span>Import</span></a>
|
||||
</li>
|
||||
|
||||
{% if active_link == 'adm-bills' %}
|
||||
<li class="nav-item active">
|
||||
{% else %}
|
||||
|
|
@ -285,7 +295,7 @@
|
|||
<div class="container-fluid" >
|
||||
|
||||
|
||||
<div id="maincontent" style="min-height: 100%; margin-top: 85px;" >
|
||||
<div id="maincontent" style="min-height: 100%; margin-top: 155px;" >
|
||||
<!-- MESSAGES -->
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
|
|
@ -532,7 +542,7 @@ function removeNotification(notifyid){
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$(document).on('click', function (e) {
|
||||
|
||||
if(e.target["id"] != 'chatButton'){
|
||||
|
|
@ -540,13 +550,13 @@ $(document).on('click', function (e) {
|
|||
$("#chat_alluserscontent").fadeOut();
|
||||
}
|
||||
}
|
||||
});
|
||||
});*/
|
||||
</script>
|
||||
|
||||
|
||||
<!-- WEBSOCKETS -->
|
||||
<script type="text/javascript">
|
||||
|
||||
/*
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#chat_alluserscontent").hide();
|
||||
|
|
@ -568,9 +578,7 @@ $(document).ready(function(){
|
|||
//HANDLER FOR ALL PUSHNOTIFICATIONS
|
||||
if(e["data"].split("__")[0] == "pushnotification"){
|
||||
|
||||
/*
|
||||
Check for Chat-Message in CHatview or invisible-Browser
|
||||
*/
|
||||
|
||||
tempsplit = e["data"].split("__");
|
||||
finalsplit = tempsplit[1].split(" ");
|
||||
|
||||
|
|
@ -720,5 +728,5 @@ $("#chatButton").click(function(){
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
*/
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{% extends "adm/adm_base.html" %}
|
||||
{% block content %}
|
||||
{% load adm_tags %}
|
||||
<div class="content-section col-12">
|
||||
<h4>Agenturimport der Agentur {{agency.name}}</h4>
|
||||
<small>Die Seite nicht verlassen oder neu laden!</small>
|
||||
<hr>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
{% extends "adm/adm_base.html" %}
|
||||
{% block content %}
|
||||
{% load adm_tags %}
|
||||
<div class="content-section col-12">
|
||||
<h4>Agenturimport</h4>
|
||||
<small>Agenturen können hier importiert werden und erhalten einen detallierten Bericht. Bereits importierte Agenturen speichern ihre MainGroupID in Nextcloud</small>
|
||||
<hr>
|
||||
<table class="table table-hover" id="agdata" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Agenturname</th>
|
||||
<th scope="col">Importierstatus</th>
|
||||
<th scope="col"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody >
|
||||
{% for ele in agencys %}
|
||||
<tr>
|
||||
<td><a href="{% url 'adm-agency-single' ele.pk %}">{{ele.name}}</a></td>
|
||||
<td></td>
|
||||
<td>
|
||||
{% if ele.importid|length == 0 %}
|
||||
<a href="{% url 'adm-import-flow' ele.pk %}" class="btn btn-danger btn-sm">Agentur jetzt zu Nextcloud migrieren</a>
|
||||
{% else %}
|
||||
Agentur importiert
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#agdata').DataTable({
|
||||
order: [1, 'desc'],
|
||||
"language": {
|
||||
"search" : "Suche",
|
||||
"info": "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
|
||||
"lengthMenu": "Zeige _MENU_ Einträge",
|
||||
"zeroRecords": "Nichts gefunden",
|
||||
"infoEmpty": "Keine Einträge",
|
||||
"paginate": {
|
||||
"first": "Erste",
|
||||
"last": "Letzte",
|
||||
"next": "Nächste",
|
||||
"previous": "Zurück"
|
||||
},
|
||||
},
|
||||
"pageLength": 50,
|
||||
"buttons" : {
|
||||
"className" : "btn-danger"
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
|
@ -10,6 +10,8 @@ Permissions definiert in models.py bei USERS und dann hier vor die View geschrie
|
|||
urlpatterns = [
|
||||
path('', AdmMain.as_view(), name='adm-main'),
|
||||
path('ag/', AdmAgencys.as_view(), name="adm-agencys"),
|
||||
path('import/', AdmImport.as_view(), name="adm-import"),
|
||||
path('doimport/<int:pk>', AdmImportFlow.as_view(), name="adm-import-flow"),
|
||||
path('us/', AdmUsers.as_view(), name="adm-users"),
|
||||
path('agsingle/<int:agpk>', AdmAgencySingle.as_view(), name="adm-agency-single"),
|
||||
path('ad/del/<int:pk>', delAgency.as_view(), name='adm-agency-delete'),
|
||||
|
|
|
|||
37
adm/views.py
37
adm/views.py
|
|
@ -677,3 +677,40 @@ class AdmAddBreak(CreateView):
|
|||
|
||||
|
||||
|
||||
|
||||
'''
|
||||
IMPORT AGENCY
|
||||
'''
|
||||
class AdmImport(TemplateView):
|
||||
template_name="adm/adm_import_overview.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context.update({'active_link' : 'adm-import'})
|
||||
context.update({'agencys' : Agency.objects.all()})
|
||||
return context
|
||||
|
||||
from django.contrib.auth.models import Group
|
||||
class AdmImportFlow(TemplateView):
|
||||
template_name="adm/adm_import_flow.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context.update({'active_link' : 'adm-import'})
|
||||
agency = Agency.objects.get(pk=kwargs.get("pk"))
|
||||
# Agency itself
|
||||
context.update({'agency' : agency})
|
||||
|
||||
# Users in that Agency
|
||||
context.update({'users' : User.objects.filter(profile__agency=agency)})
|
||||
|
||||
# Groups of the Agency
|
||||
groups = Group.objects.all()
|
||||
ag_pk = str(agency.pk)
|
||||
ag_groups = []
|
||||
for g in groups:
|
||||
if(ag_pk in g.name):
|
||||
ag_groups.append(g)
|
||||
context.update({'groups' : ag_groups})
|
||||
|
||||
return context
|
||||
|
|
|
|||
|
|
@ -14,5 +14,6 @@ urlpatterns = [
|
|||
# MIGRATION
|
||||
path('migrateagencyusers/<int:pk>', views.migrateAgencyUsers, name="api-migrateagencyusers"),
|
||||
# EXTERNAL FROM NC
|
||||
path('logout/<str:uid>', views.test, name="api-test"),
|
||||
path('logout/<str:uid>', views.apilogout, name="api-logout"),
|
||||
path('uschanged/<str:uid>/<str:sid>', views.userChangedInNc, name="api-userchanged"),
|
||||
]
|
||||
35
api/views.py
35
api/views.py
|
|
@ -12,9 +12,10 @@ from rest_framework.authentication import SessionAuthentication, BasicAuthentica
|
|||
from rest_framework.decorators import authentication_classes
|
||||
from chat.models import ChatRoom, ChatMessage
|
||||
from django.http import HttpResponseRedirect,HttpResponse, JsonResponse
|
||||
|
||||
from django.contrib.sessions.models import Session
|
||||
from timemanagement.models import Absence
|
||||
|
||||
from django.conf import settings
|
||||
from digitaleagentur.utils import *
|
||||
|
||||
class GetUserId(APIView):
|
||||
#permission_classes = (IsAuthenticated,) # <-- And here
|
||||
|
|
@ -90,12 +91,34 @@ def migrateAgencyUsers(request, pk):
|
|||
return JsonResponse(datapackage)
|
||||
|
||||
|
||||
from django.contrib.auth import login, logout
|
||||
from django.contrib.auth import update_session_auth_hash
|
||||
from django.contrib.sessions.models import Session
|
||||
|
||||
|
||||
@api_view(['GET', ])
|
||||
def test(request, uid):
|
||||
def apilogout(request, uid):
|
||||
print("LOGOUT: " + str(uid))
|
||||
user = User.objects.get(username=uid)
|
||||
[s.delete() for s in Session.objects.all() if s.get_decoded().get('_auth_user_hash') == user.get_session_auth_hash()]
|
||||
return JsonResponse({'res' : 'ok'})
|
||||
|
||||
|
||||
# This function change the Username of a user, when it was changed in NextCloud! Works only for the own user :) !
|
||||
import xmltodict, json, requests
|
||||
@api_view(['GET'], )
|
||||
def userChangedInNc(request, uid, sid):
|
||||
user = User.objects.get(username=uid)
|
||||
if(user.is_authenticated and getNCLoggedUserBySession(sid) == uid):
|
||||
nc_login_headers = {'Authorization' : 'Bearer ' + sid}
|
||||
r = requests.get(settings.NEXTCLOUD_URL + "ocs/v1.php/cloud/users/" + uid, headers=nc_login_headers)
|
||||
xpars = xmltodict.parse(r.text)
|
||||
js = json.dumps(xpars)
|
||||
final_json = json.loads(js)
|
||||
new_displayname = final_json['ocs']['data']['displayname'].split(" ")
|
||||
user.first_name = new_displayname[0]
|
||||
new_last_name = ""
|
||||
new_displayname.pop(0)
|
||||
for ele in new_displayname:
|
||||
new_last_name += " " + ele
|
||||
user.last_name = new_last_name
|
||||
user.save()
|
||||
return JsonResponse({"status" : "ok!"})
|
||||
return JsonResponse({"status" : "NO AUTH"})
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
{% load crispy_forms_tags %}
|
||||
<div class="row">
|
||||
<div class="col-6 mt-3">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Modul</th>
|
||||
<th scope="col">Aktiviert</th>
|
||||
<th scope="col">Einstellungen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -14,9 +14,9 @@
|
|||
<input type="hidden" name="form_type" value="agencymodform">
|
||||
<input type="hidden" name="settings_area" value="moduls">
|
||||
{% for formfield in modulform %}
|
||||
{% if formfield.name == 'module_organigramm' or formfield.name == 'module_timemanagement' %}
|
||||
<tr>
|
||||
<td>{{formfield.label_tag}}</td>
|
||||
<td>{{formfield}}</td>
|
||||
<td>
|
||||
{% if formfield.name == 'module_organigramm' and user.profile.agency.module_organigramm %}
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="javascript:$('#modulesettings_{{formfield.name}}').modal('toggle');"><i class="fas fa-cog"></i></button>
|
||||
|
|
@ -25,13 +25,13 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="submit" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="Mit dem Speichern wird die Seite neu geladen, damit alle Einstellungen aktualisiert werden. Werden Module deaktiviert, gehen die Einstellungen und zugewiesenen Rechte nicht verloren.">Moduleinstellungen aktualisieren</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% for formfield in modulform %}
|
||||
<div class="modal fade" id="modulesettings_{{formfield.name}}" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg " role="document" >
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
{% load crispy_forms_tags %}
|
||||
<div class="col-6 mt-3">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Modul</th>
|
||||
<th scope="col">Aktiviert</th>
|
||||
<th scope="col">Einstellungen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="module_checkboxes">
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="form_type" value="agencymodform">
|
||||
<input type="hidden" name="settings_area" value="moduls">
|
||||
{% for formfield in modulform %}
|
||||
<tr>
|
||||
<td>{{formfield.label_tag}}</td>
|
||||
<td>{{formfield}}</td>
|
||||
<td>
|
||||
{% if formfield.name == 'module_organigramm' and user.profile.agency.module_organigramm %}
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="javascript:$('#modulesettings_{{formfield.name}}').modal('toggle');"><i class="fas fa-cog"></i></button>
|
||||
{% elif formfield.name == 'module_timemanagement' and user.profile.agency.module_timemanagement %}
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="javascript:$('#modulesettings_{{formfield.name}}').modal('toggle');"><i class="fas fa-cog"></i></button>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="submit" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="Mit dem Speichern wird die Seite neu geladen, damit alle Einstellungen aktualisiert werden. Werden Module deaktiviert, gehen die Einstellungen und zugewiesenen Rechte nicht verloren.">Moduleinstellungen aktualisieren</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% for formfield in modulform %}
|
||||
<div class="modal fade" id="modulesettings_{{formfield.name}}" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg " role="document" >
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Moduleinstellungen {{formfield.label_tag}}</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{% if formfield.name == 'module_organigramm' %}
|
||||
{% block modulesettings_organigramm %}
|
||||
{% include "dasettings/modulesettings_organigramm.html" %}
|
||||
{% endblock %}
|
||||
{% elif formfield.name == 'module_timemanagement' %}
|
||||
{% block modulesettings_tm %}
|
||||
{% include "dasettings/modulesettings_timemanagement.html" %}
|
||||
{% endblock %}
|
||||
{% else %}
|
||||
Keine Einstellungen vorhanden.
|
||||
{% endif %}
|
||||
{% if formfield.name == 'module_organigramm' and user.profile.agency.module_organigramm %}
|
||||
<div class="modal-footer">
|
||||
|
||||
<button id="" type="button" onclick="javascript:updateOrganigrammSettings()" class="btn btn-primary" data-dismiss="modal" >Speichern</button>
|
||||
|
||||
<button type="button" class="btn" data-dismiss="modal">Abbrechen</button>
|
||||
</div>
|
||||
{% elif formfield.name == 'module_timemanagement' and user.profile.agency.module_timemanagement %}
|
||||
<div class="modal-footer">
|
||||
|
||||
<button id="" type="button " onclick="javascript:updateTmSettings()" class="btn btn-primary" data-dismiss="modal" >Speichern</button>
|
||||
|
||||
<button type="button" class="btn" data-dismiss="modal">Abbrechen</button>
|
||||
</div>
|
||||
{% else %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">Schließen</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
@ -37,9 +37,11 @@
|
|||
<h3>Einstellungen</i></b>{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Hier können Agenturweite Einstellungen (Mitarbeiter, Gruppen, Agenturinfos, Bereiche und Tätigkeiten, Abrechnung, Module usw.) verwaltet werden." class="far fa-question-circle"></i></small>{% endif %}</h3>
|
||||
<hr>
|
||||
<ul class="nav nav-tabs" id="settingsTabs" role="tablist">
|
||||
<!--
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="profil-tab" data-toggle="tab" href="#profil" role="tab" aria-controls="profil" aria-selected="false" ><i class="fas fa-user"></i> Profil</a>
|
||||
</li>
|
||||
-->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="notifications-tab" data-toggle="tab" href="#notifications" role="tab" aria-controls="notifications-tab" aria-selected="false"><i class="fas fa-bell"></i> Benachrichtigungen</a>
|
||||
</li>
|
||||
|
|
@ -79,14 +81,18 @@
|
|||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
<div class="tab-content" id="settingsTabsContent">
|
||||
<!--
|
||||
<div class="tab-pane fade show" id="profil" role="tabpanel" aria-labelledby="profil-tab">
|
||||
<h5 class="mt-3">Profileinstellungen{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Hier können Sie Einstellungen an ihrem Profil vornehmen (E-Mail, Passwort und, ob die Tooltips angezeigt werden sollen). Alle anderen Einstellungen werden von Mitarbeitern mit entsprechenden Gruppenrechten verwaltet." class="far fa-question-circle"></i></small>{% endif %}</h5>
|
||||
<hr>
|
||||
{% block profil_content %}
|
||||
{% include "dasettings/profil_content.html" %}
|
||||
{% endblock %}
|
||||
WURDE AUSKOMMENTNTIERT, IST ABER DJANGO
|
||||
block profil_content
|
||||
include "dasettings/profil_content.html"
|
||||
endblock
|
||||
</div>
|
||||
-->
|
||||
<div class="tab-pane fade" id="notifications" role="tabpanel" aria-labelledby="notifications-tab">
|
||||
<h5 class="mt-3">Benachrichtigungen{% if request.user.profile.showtooltips %} <small><i data-toggle="tooltip" data-placement="top" title="Stellen Sie hier ein, welche Art der Benachrichtigung (E-Mail oder Push) Sie für welches Ereignis (Gruppenzuweisungen, Veröffentlichung eines Standards, neue Agenturnews usw.) erhalten möchten." class="far fa-question-circle"></i></small>{% endif %}</h5>
|
||||
|
||||
|
|
@ -170,7 +176,7 @@
|
|||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
var defaultsettingsview = "profil";
|
||||
var defaultsettingsview = "notifications";
|
||||
/* COOKIE FOR SAVING OPEN TAB */
|
||||
$(document).ready(function(){
|
||||
|
||||
|
|
@ -192,14 +198,14 @@ var defaultsettingsview = "profil";
|
|||
}
|
||||
else{
|
||||
|
||||
$("#profil-tab").addClass("active");
|
||||
$('#profil').tab('show');
|
||||
$("#notifications-tab").addClass("active");
|
||||
$('#notifications').tab('show');
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
$("#profil-tab").addClass("active");
|
||||
$('#profil').tab('show');
|
||||
$("#notifications-tab").addClass("active");
|
||||
$('#notifications').tab('show');
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from timemanagement.models import *
|
||||
from digitaleagentur.timemanagement_utils import *
|
||||
from django.conf import settings
|
||||
from django.shortcuts import redirect
|
||||
'''
|
||||
|
||||
Hier sind Funktion implementiert, die in verschiedenen Module benötigt werden
|
||||
|
|
@ -98,10 +100,43 @@ def checkAbsenceWorkdayCollideDelete(absence):
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# NC LOGIN
|
||||
'''
|
||||
|
||||
A User has to be logged in in NC. If yes, we check the user-status and retrieving the userId. If the logged user by this session is the same we want to see in Django, than the user will logged in.
|
||||
|
||||
Double-Check: Logged-Session from NC (session-id cannot be hacked cause it is serverside) and we check userId local, django and NC
|
||||
|
||||
'''
|
||||
import xmltodict, json, requests
|
||||
import urllib.request as urllib2
|
||||
from django.contrib.auth import login, logout
|
||||
def ncLogin(request, uid):
|
||||
try:
|
||||
logout(request)
|
||||
useridFromServer = getNCLoggedUserBySession(request.COOKIES['nc_session_id'])
|
||||
if(uid == urllib2.unquote(request.COOKIES['nc_username']) and useridFromServer == uid):
|
||||
login(request, User.objects.get(username=urllib2.unquote(request.COOKIES['nc_username'])))
|
||||
return redirect('users-dashboard')
|
||||
#return redirect('login')
|
||||
except:
|
||||
return redirect('users-dashboard')
|
||||
|
||||
'''
|
||||
getNCLoggedUserBySession
|
||||
|
||||
Returns the UserId of the user in the given session
|
||||
|
||||
@params:
|
||||
- sid (string) from nc_session_id, saved in the server and cookie
|
||||
'''
|
||||
def getNCLoggedUserBySession(sid):
|
||||
nc_login_headers = {'Authorization' : 'Bearer ' + sid}
|
||||
r = requests.get(settings.NEXTCLOUD_URL + "ocs/v2.php/apps/user_status/api/v1/user_status", headers=nc_login_headers)
|
||||
xpars = xmltodict.parse(r.text)
|
||||
js = json.dumps(xpars)
|
||||
final_json = json.loads(js)
|
||||
return final_json['ocs']['data']['userId']
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class NewsManagement(LoginRequiredMixin, ListView):
|
|||
# Loading only user same agency
|
||||
# Change context and return for template-data
|
||||
def get_context_data(self, **kwargs):
|
||||
|
||||
filterdate = timezone.now()
|
||||
news = News.objects.filter(agency__pk=self.request.user.profile.agency.pk).filter(go_online_on__lt=filterdate).filter(go_offline_on__gt=filterdate).order_by('-created_date') | News.objects.filter(agency__pk=self.request.user.profile.agency.pk).filter(go_online_on__lt=filterdate).filter(go_offline_on__isnull=True).order_by('-created_date')
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,8 @@ class Agency(models.Model):
|
|||
|
||||
vve = models.CharField(default="", max_length=200, blank=True)
|
||||
|
||||
|
||||
# NC IMPORT
|
||||
importid = models.CharField(default="", max_length=200, blank=True)
|
||||
|
||||
# RECOVERDIR
|
||||
module_recoverdir = models.BooleanField(default=False)
|
||||
|
|
|
|||
|
|
@ -80,17 +80,14 @@ import xmltodict, json
|
|||
import urllib.request as urllib2
|
||||
from django.contrib.auth import login, logout
|
||||
def ncLogin(request, uid):
|
||||
logout(request)
|
||||
nc_login_headers = {'Authorization' : 'Bearer ' + request.COOKIES['nc_session_id']}
|
||||
r = requests.get(settings.NEXTCLOUD_URL + "ocs/v2.php/apps/user_status/api/v1/user_status", headers=nc_login_headers)
|
||||
xpars = xmltodict.parse(r.text)
|
||||
js = json.dumps(xpars)
|
||||
final_json = json.loads(js)
|
||||
useridFromServer = final_json['ocs']['data']['userId']
|
||||
if(uid == urllib2.unquote(request.COOKIES['nc_username']) and useridFromServer == uid):
|
||||
login(request, User.objects.get(username=urllib2.unquote(request.COOKIES['nc_username'])))
|
||||
try:
|
||||
logout(request)
|
||||
if(uid == urllib2.unquote(request.COOKIES['nc_username']) and getNCLoggedUserBySession(request.COOKIES['nc_session_id'])):
|
||||
login(request, User.objects.get(username=urllib2.unquote(request.COOKIES['nc_username'])))
|
||||
return redirect('users-dashboard')
|
||||
return redirect('login')
|
||||
except:
|
||||
return redirect('users-dashboard')
|
||||
return redirect('login')
|
||||
|
||||
|
||||
def getICSFile(request, ag):
|
||||
|
|
|
|||
Loading…
Reference in New Issue