Ajout du module comm_op dans reskreen

This commit is contained in:
Ambulance Clerc
2023-10-11 11:44:20 +02:00
parent 7d37cfd1df
commit 808dfd9ed3
4 changed files with 40 additions and 9 deletions

View File

@@ -8,7 +8,7 @@ from django.contrib.auth.models import User
class MessageAdmin(admin.ModelAdmin): class MessageAdmin(admin.ModelAdmin):
always_show_username = True always_show_username = True
fieldsets = [ fieldsets = [
(None, {'fields': ['sKey','sTitle','sDesc']}), (None, {'fields': ['sKey','sTitle','sDesc', 'bDone']}),
('Date information', {'fields': ['dtStart','dtEnd']}), ('Date information', {'fields': ['dtStart','dtEnd']}),
('Auteur', {'fields': ['Author']}), ('Auteur', {'fields': ['Author']}),
] ]

View File

@@ -1,9 +1,11 @@
from django.db import models from django.db import models
from django.conf import settings from django.conf import settings
from django.utils import timezone from django.utils import timezone
import uuid
# Create your models here. # Create your models here.
class comm_opMessage(models.Model): class comm_opMessage(models.Model):
uuid = models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True)
sKey = models.CharField("Clé d'identification", max_length=100) sKey = models.CharField("Clé d'identification", max_length=100)
sTitle = models.CharField('Titre', max_length=250) sTitle = models.CharField('Titre', max_length=250)
sDesc = models.TextField('Description') sDesc = models.TextField('Description')

View File

@@ -12,11 +12,10 @@
{% if task.done %} {% if task.done %}
{{task.key}} {{task.key}}
{% else %} {% else %}
<a href="op/edit/{{task.uiid}}">{{task.key}}</a> <a href="op/edit/{{task.uuid}}">{{task.key}}</a>
{% endif %} {% endif %}
</span><br> </span><br>
{{task.str_start_date}} - {{task.str_end_date}}<br> {{task.str_start_date}} {% if task.str_end_date != None %}- {{task.str_end_date}} {% endif %}
{{task.str_start_time}} - {{task.str_end_time}}
</td>&nbsp;&nbsp;&nbsp;&nbsp; </td>&nbsp;&nbsp;&nbsp;&nbsp;
<td style="{% if task.done %}text-decoration:line-through{% endif %}"> <td style="{% if task.done %}text-decoration:line-through{% endif %}">
{% if task.href != "" %} {% if task.href != "" %}

View File

@@ -6,6 +6,7 @@ from django.template import loader
from django.views.decorators.clickjacking import xframe_options_exempt from django.views.decorators.clickjacking import xframe_options_exempt
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
import caldav as cal import caldav as cal
from datetime import datetime, timedelta, time from datetime import datetime, timedelta, time
@@ -15,6 +16,20 @@ from datetime import datetime, timedelta, time
from mycaldav.models import * from mycaldav.models import *
from mycaldav.settings import * from mycaldav.settings import *
from mycaldav.export_team_pdf import * from mycaldav.export_team_pdf import *
from comm_op.models import comm_opMessage
class caldav_item:
def __init__(self):
self.uuid = ""
self.name = ""
self.desc = ""
self.key = ""
self.done = False
self.href = "#"
self.str_start_date = ""
self.str_end_date = ""
@xframe_options_exempt @xframe_options_exempt
@@ -37,8 +52,10 @@ def view_task_edit_caldav(request, uuid):
def view_op_edit_caldav(request, uuid): def view_op_edit_caldav(request, uuid):
print(uuid) print(uuid)
myClient = cls_caldav_client() object = comm_opMessage.objects.get(pk=uuid)
myClient.mark_as_done_task(calandar=myClient.a_op,uuid=uuid) object.bDone = True
object.save()
return view_op_caldav(request) return view_op_caldav(request)
def view_vhc_edit_caldav(request, uuid): def view_vhc_edit_caldav(request, uuid):
@@ -72,10 +89,23 @@ def view_road_caldav(request):
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
@xframe_options_exempt @xframe_options_exempt
def view_op_caldav(request): def view_op_caldav(request):
o_caldav = cls_caldav(url=caldav_cfg["op"]) o_items = comm_opMessage.objects.filter(bDone=False, dtStart__lte= datetime.today() + timedelta(days=1))
o_caldav.get_caldav_data(periode=1) all_items = []
for item in o_items:
temp_item = caldav_item()
temp_item.uuid = item.uuid
temp_item.name = item.sTitle
temp_item.desc = item.sDesc
temp_item.key = item.sKey
temp_item.str_start_date = str(item.dtStart.day) + "." + str(item.dtStart.month)
if item.dtEnd != None:
temp_item.str_end_date = str(item.dtEnd.day) + "." + str(item.dtEnd.month)
else:
temp_item.str_end_date = None
all_items.append(temp_item)
template = loader.get_template("op/op_view.html") template = loader.get_template("op/op_view.html")
context = {'latest_task_list': o_caldav.items} context = {'latest_task_list': all_items}
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
@xframe_options_exempt @xframe_options_exempt