Abwesenheiten Public Access

This commit is contained in:
holger.trampe 2021-01-07 12:41:58 +01:00
parent 0cd7f96274
commit 31cf2714f8
7 changed files with 139 additions and 14 deletions

BIN
dump.rdb

Binary file not shown.

View File

@ -122,12 +122,15 @@ def getLocalWeather(user):
agency = user.profile.agency
if len(agency.city) > 0:
# Try to request Weather-Info. If request failed, no weatherinfo is showing
try:
r = requests.get('http://api.openweathermap.org/data/2.5/weather?q='+agency.city+'&lang=de&units=metric&APPID=e37ac762a3c233f5fbc434c72df7961f')
weatherinfo = r.json()
print(weatherinfo)
weatherinfodata.append("| " + weatherinfo['weather'][0]['description'])
weatherinfodata.append(weatherinfo['weather'][0]['icon'])
weatherinfodata.append(str(weatherinfo['main']['temp']) + " °C")
except:
weatherinfodata = ""
else:
weatherinfodata = ""
@ -950,4 +953,25 @@ def getBaseURLIcsLink(agency):
return settings.BASE_URL + "ics/" + str(agency.pk)
@register.simple_tag
def getBaseURLIcsLinkAll(agency):
return settings.BASE_URL + "icsall/" + str(agency.pk)
@register.simple_tag
def getBaseURLIcsEx(agency):
return settings.BASE_URL + "icspublic/" + str(agency.agencycalurl) + "/" + str(agency.pk)
@register.simple_tag
def getBaseURLIcsExAll(agency):
return settings.BASE_URL + "icspublicall/" + str(agency.agencycalurl_all) + "/" + str(agency.pk)

View File

@ -197,20 +197,48 @@
<div class="modal fade" tabindex="-1" id="showICSLink" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">ICS-Kalenderlink</h5>
<h5 class="modal-title">Links für Abwesenheitskalender</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Kopieren Sie diesen Link in Ihren Kalender und abonnieren den Abwesenheitskalender Ihrer Agentur: <br />
<h4><b>Kalenderlinks mit Authentifzierung</b></h4>
{% getBaseURLIcsLink request.user.profile.agency as icsurl %}
<b>{{icsurl}}</b>
<span>Abwesenheit{% if request.user.profile.showtooltips %}&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Dieser Link zeigt alle Abwesenheiten der Agentur an. Es wird eine Anmeldung von Nöten. Funktioniert nur in Mailprogrammen oder Smartphones, nicht aber bei Online-Kalenderdiensten wie Google. Hierfür muss die externe Freigabe in den Moduleinstellungen aktiviert werden." class="far fa-question-circle"></i></small>&nbsp;{% endif %}<br /></span><b>{{icsurl}}</b>
<a href="#\" onclick="javascript:copyURL('{{icsurl}}')"><i class="far fa-copy"></i></a>
<span id="icsurl" style="display: none;">Kopiert!</span>
{% if request.user|usergperm:"absencemanager" %}
<br />
{% getBaseURLIcsLinkAll request.user.profile.agency as icsurlall %}
<span>Abwesenheit inkl. Grund{% if request.user.profile.showtooltips %}&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Dieser Link zeigt alle Abwesenheiten der Agentur inkl. Grund für die Abwesenheit an. Es wird eine Anmeldung von Nöten. Funktioniert nur in Mailprogrammen oder Smartphones, nicht aber bei Online-Kalenderdiensten wie Google. Hierfür muss die externe Freigabe in den Moduleinstellungen aktiviert werden." class="far fa-question-circle"></i></small>{% endif %}<br /></span><b>{{icsurlall}}</b>
<a href="#\" onclick="javascript:copyURLAll('{{icsurlall}}')"><i class="far fa-copy"></i></a>
<span id="icsurlall" style="display: none;">Kopiert!</span>
{% endif %}
{% if request.user.profile.agency.agencycal_publicstatus == 1 %}
<hr>
{% getBaseURLIcsEx request.user.profile.agency as icsurlex %}
<h4><b>Öffentliche Links ohne Authentifizierung (z.B. für Google-Kalender)</b></h4>
<span>Abwesenheit{% if request.user.profile.showtooltips %}&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Dieser Link zeigt alle Abwesenheiten der Agentur an. Es wird keine Anmeldung benötigt. Geben Sie diesen Link auf keinen Fall an Dritte weiter!" class="far fa-question-circle"></i></small>&nbsp;{% endif %}<br /></span><b>{{icsurlex}}</b>
<a href="#\" onclick="javascript:copyURLEx('{{icsurlex}}')"><i class="far fa-copy"></i></a>
<span id="icsurlex" style="display: none;">Kopiert!</span>
{% if request.user|usergperm:"absencemanager" %}
<br />
{% getBaseURLIcsExAll request.user.profile.agency as icsurlexall %}
<span>Abwesenheit inkl. Grund{% if request.user.profile.showtooltips %}&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Dieser Link zeigt alle Abwesenheiten der Agentur inkl. Grund für die Abwesenheit an. Es wird keine Anmeldung benötigt. Geben Sie diesen Link auf keinen Fall an Dritte weiter!" class="far fa-question-circle"></i></small>&nbsp;{% endif %}<br /></span><b>{{icsurlexall}}</b>
<a href="#\" onclick="javascript:copyURLExAll('{{icsurlexall}}')"><i class="far fa-copy"></i></a>
<span id="icsurlexall" style="display: none;">Kopiert!</span>
{% endif %}
{% endif %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary " data-dismiss="modal">Schließen</button>
@ -219,8 +247,6 @@
</div>
</div>
<!-- MODAL -->
<div class="modal fade" tabindex="-1" id="updateAbsenceToConfirm" data-backdrop="static">
<div class="modal-dialog" role="document">
@ -352,6 +378,41 @@ function copyURL(urldata){
$("#icsurl").show();
}
function copyURLAll(urldata){
console.log(urldata);
var $temp = $("<input>");
$("#showICSLink").append($temp);
$temp.val(urldata).focus();
$temp.val(urldata).select();
document.execCommand("copy");
$temp.remove();
$("#icsurlall").show();
}
function copyURLEx(urldata){
console.log(urldata);
var $temp = $("<input>");
$("#showICSLink").append($temp);
$temp.val(urldata).focus();
$temp.val(urldata).select();
document.execCommand("copy");
$temp.remove();
$("#icsurlex").show();
}
function copyURLExAll(urldata){
console.log(urldata);
var $temp = $("<input>");
$("#showICSLink").append($temp);
$temp.val(urldata).focus();
$temp.val(urldata).select();
document.execCommand("copy");
$temp.remove();
$("#icsurlexall").show();
}
var absencetowork = "";
var absencestring_confirm = "";

View File

@ -6,7 +6,7 @@
<h3>{{timemessage}}, {{request.user.first_name}} {{request.user.last_name}}!</h3>
<small>Letzter Login: {{ request.user.last_login }}
{% getlocalweather request.user as weatherdata %}
{% if request.user.profile.agency.city|length > 0 %}
{% if request.user.profile.agency.city|length > 0 and weatherdata.0 != None %}
{{weatherdata.0}}<img src='https://openweathermap.org/img/wn/{{weatherdata.1}}.png' width="45px" style="margin-bottom: -5px; padding-right: -20px; margin-left: -10px; margin-top: -15px; margin-right: -6px;">{{weatherdata.2}}</small>
{% endif %}
<hr>

View File

@ -41,7 +41,8 @@ urlpatterns = [
path('dacrondaily/<slug:code>', views.cronactionsdaily, name="cronmaindaily"),
path('dacronbill/<slug:code>', views.cronactionsbill, name="cronmainbill"),
path('isalive/', views.isAlive, name="isalive"),
path('ics/<int:ag>', views.getICSFile, name="getics")
path('ics/<int:ag>', views.getICSFile, name="getics"),
path('icsall/<int:ag>', views.getICSFileAll, name="geticsall")
]

View File

@ -78,8 +78,11 @@ def getICSFile(request, ag):
e = Event()
e.name = ab.user.first_name + " " + ab.user.last_name + " abwesend"
e.uid = "da-ab-" + str(ab.pk)
e.begin = ab.start
e.end = ab.end
e.allday = True
c.events.add(e)
return HttpResponse(c, content_type='text/calendar')
@ -89,6 +92,42 @@ def getICSFile(request, ag):
response['WWW-Authenticate'] = 'Basic realm="%s"' % realm
return response
def getICSFileAll(request, ag):
#if request.user.profile.agency.pk == ag:
if 'HTTP_AUTHORIZATION' in request.META:
auth = request.META['HTTP_AUTHORIZATION'].split()
if len(auth) == 2:
if auth[0].lower() == "basic":
temp = base64.b64decode(auth[1] + "==")
username = temp.decode("utf-8").split(":")[0]
passwd = temp.decode("utf-8").split(":")[1]
user = authenticate(username=username, password=passwd)
if user is not None:
if user.is_active:
if user.profile.agency.pk == ag and user.has_perm('users.absencemanager'):
request.user = user
c = Calendar()
absencedays = Absence.objects.filter(agency=ag)
for ab in absencedays:
e = Event()
e.name = ab.user.first_name + " " + ab.user.last_name + " | " + ab.reason.name
e.uid = "da-ab-" + str(ab.pk)
e.begin = ab.start
e.end = ab.end
e.allday = True
c.events.add(e)
return HttpResponse(c, content_type='text/calendar')
realm = ""
response = HttpResponse()
response.status_code = 401
response['WWW-Authenticate'] = 'Basic realm="%s"' % realm
return response
'''
Standardstruktur laden