Zwischenstand Kalender und Wettergeschichte

This commit is contained in:
holger.trampe 2021-01-07 10:06:21 +01:00
parent 3da29bdef0
commit 0cd7f96274
10 changed files with 146 additions and 7 deletions

View File

@ -40,8 +40,42 @@
</table>
<small>Abwesenheitskategorien legen fest, wie sich eine Abwesenheit bzgl. Bestätigung durch einen Mitarbeiter mit entsprechenden Rechten und eines Vertretes verhält.</small>
<hr>
<h4 >Externer Zugriff{% if request.user.profile.showtooltips %}&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Legen Sie fest, wie Mitarbeiter auf die Abwesenheitsinformationen zugreifen können. Sollten Sie hier den öffentlichen Zugriff ohne Authentifizierung wählen, dürfen die Links nicht weitergegeben werden, da sonst Unbefugte Zugriff auf agenturinterne Daten haben. Ihre Agentur trägt für die Geheimhaltung dieser Links die Verantwortung." class="far fa-question-circle"></i></small>{% endif %}
</h4>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="allowExternalAccess" {% if request.user.profile.agency.agencycal_publicstatus == 1 %} checked {% endif %} onchange="javascript:updateExAccess()">
<label class="form-check-label" for="allowExternalAccess">
Öffentlichen Zugriff ohne Anmeldung erlauben (z.B. für Google-Kalender)
</label>
</div>
<hr>
<a class="btn btn-primary mb-2" href="{% url 'tm-managemenetfreedays' %}">Feiertage bearbeiten</a>
<script type="text/javascript">
function updateExAccess(){
$.ajax(
{
type: "GET",
url: "{% url 'dasettings-ajax' %}",
data:{
newvalue : $("#allowExternalAccess").prop("checked"),
agency : {{request.user.profile.agency.pk}},
action : 'changeexternalaccess'
},
success: function( data )
{
$("#modulesettings_module_timemanagement").modal("toggle");
$("#externalAccessUpdate").modal("show");
}
});
}
function updateTmSettings(){
$.ajax(
{

View File

@ -432,7 +432,25 @@ $(document).ready(function(){
</div>
<!-- Modal -->
<div class="modal fade" id="externalAccessUpdate" tabindex="20" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Externer Zugriff aktualisiert</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Die Zugriffseinstellung für den externen Zugriff wurden aktualisiert.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Schließen</button>
</div>
</div>
</div>
</div>

View File

@ -999,11 +999,37 @@ def SettingsAjaxRouter(request):
if(request.user.has_perm('users.usermanager') and request.user.profile.agency == tempuser.profile.agency):
deluntildate = tempuser.usertime.usetime_start
delete_days = Workday.objects.filter(user=tempuser, start__lt=deluntildate).delete()
return JsonResponse({"success" : success, "data" : data})
# Change external Access
elif request.method == "GET" and request.GET['action'] == "changeexternalaccess" :
if(request.user.has_perm('users.absencemanager') and request.user.profile.agency.pk == int(request.GET['agency'])):
if(request.GET['newvalue'] == "true"):
request.user.profile.agency.agencycal_publicstatus = 1
if len(request.user.profile.agency.agencycalurl) == 0:
request.user.profile.agency.agencycalurl = randomStringNum(30)
request.user.profile.agency.agencycalurl_all = randomStringNum(30)
request.user.profile.agency.save()
else:
request.user.profile.agency.agencycal_publicstatus = 0
request.user.profile.agency.save()
else:
success = False
print("DER NICHT")
return JsonResponse({"success" : success, "data" : data})
else:
success = False
return JsonResponse({"success" : success, "data" : data})
def randomStringNum(stringLength=20):
"""Generate a random string of fixed length """
lettersAndNumbers = string.ascii_lowercase + string.digits
return ''.join(random.choice(lettersAndNumbers) for i in range(stringLength))
def loadingFreeDays(plz, year):
# Getting land
@ -1793,8 +1819,6 @@ class BillPlanUpdate(UpdateView):
else:
mail_to_send = self.request.user.profile.agency.payment_address
msg_html = render_to_string('users/newbill_mail.html', {})
send_mail('Digitale Agentur | Rechnung', 'Sehr geehrte Nutzer, es wurde eine Rechnung für Ihre digitale Agentur erstellt. Diese können Sie unter Einstellungen, Abrechnung einsehen.','noreply@digitale-agentur.com',[mail_to_send],html_message=msg_html,fail_silently=True)

BIN
dump.rdb

Binary file not shown.

View File

@ -94,6 +94,47 @@ def is_member(id, groupname):
usertocheck = User.objects.get(pk=id)
return usertocheck.groups.filter(name=groupname).exists()
# Gibt eine zeitabhängige Nachricht zurück (Guten Morgen, Guten Tag, Guten Abend)
@register.simple_tag(name="gettimemessage")
def getTimeMessage():
hour = datetime.datetime.now().hour
returnstring = ""
if hour >= 5 and hour < 11:
returnstring = "Guten Morgen"
elif hour >= 11 and hour < 18:
returnstring = "Guten Tag"
elif hour >= 18 and hour <= 23:
returnstring = "Guten Abend"
elif hour >= 0 and hour < 5:
returnstring = "Guten Abend"
return returnstring
import requests
# Gibt Wetterdaten zurück als String
@register.simple_tag(name="getlocalweather")
def getLocalWeather(user):
weatherinfodata = []
agency = user.profile.agency
if len(agency.city) > 0:
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")
else:
weatherinfodata = ""
return weatherinfodata
# Return a Filename splitted to only see the LAST element!
@register.filter(name="splitdirstyle")
def split_dir_style(dirtosplit):

View File

@ -210,7 +210,7 @@
{% getBaseURLIcsLink request.user.profile.agency as icsurl %}
<b>{{icsurl}}</b>
<a href="#\" onclick="javascript:copyURL('{{icsurl}}')"><i class="far fa-copy"></i></a>
<span id="icsurl" style="display: none;">Kopiert!</span>
<span id="icsurl" style="display: none;">Kopiert!</span>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary " data-dismiss="modal">Schließen</button>
@ -344,7 +344,8 @@
<script>
function copyURL(urldata){
var $temp = $("<input>");
$("body").append($temp);
$("#showICSLink").append($temp);
$temp.val(urldata).focus();
$temp.val(urldata).select();
document.execCommand("copy");
$temp.remove();

View File

@ -82,6 +82,12 @@ class Agency(models.Model):
phone = models.CharField(default="", max_length=50, blank=True)
agencypic = models.ImageField(default='ag_default.jpg', upload_to=picturepath_agency, blank=True)
agencycalurl = models.CharField(default="", blank=True, max_length=1000)
agencycalurl_all = models.CharField(default="", blank=True, max_length=1000)
# Gibt an, welche Schnittstellen für Kalenderlinks offen sind
# 0 = Nur Kalenderdaten per Authenzifizierung
# 1 = Kalenderdaten per Authentifizierung UND OHNE (für Google-Kalender)
agencycal_publicstatus = models.IntegerField(default=0)
# MONEY
#balance = models.FloatField(default=0.0, max_length=9, blank=True)
#nextdebiting = models.DateTimeField(default=timezone.now, blank=True)

View File

@ -2,8 +2,13 @@
{% load counter_tag %}
{% block content %}
<div class="content-section col-12">
<h3>Willkommen, {{request.user.first_name}} {{request.user.last_name}}!</h3>
<small>Letzter Login: {{ request.user.last_login }}</small>
{% gettimemessage as timemessage %}
<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 %}
{{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>
<h5>Agentur: <b>{{ request.user.profile.agency.name }}</b></h5>
<hr>

View File

@ -171,6 +171,11 @@ def randomString(stringLength=10):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
def randomStringNum(stringLength=20):
"""Generate a random string of fixed length """
lettersAndNumbers = string.ascii_lowercase + string.digits
return ''.join(random.choice(lettersAndNumbers) for i in range(stringLength))
@login_required
def toUpdate(request):
# NO AGENVYJOBS
@ -183,7 +188,12 @@ def toUpdate(request):
Auszubildender
'''
if len(request.user.profile.agency.agencycalurl) == 0:
request.user.profile.agency.agencycalurl = randomStringNum(30)
request.user.profile.agency.agencycalurl_all = randomStringNum(30)
request.user.profile.agency.save()
print("CAL-URLS updated for " + str(request.user.profile.agency.pk))
agencyjobsobject = AgencyJob.objects.filter(agency__pk=request.user.profile.agency.pk)
if(len(agencyjobsobject) == 0):