diff --git a/comm_op/admin.py b/comm_op/admin.py
index f490989..36ee0c0 100644
--- a/comm_op/admin.py
+++ b/comm_op/admin.py
@@ -8,7 +8,7 @@ from django.contrib.auth.models import User
class MessageAdmin(admin.ModelAdmin):
always_show_username = True
fieldsets = [
- (None, {'fields': ['sKey','sTitle','sDesc']}),
+ (None, {'fields': ['sKey','sTitle','sDesc', 'bDone']}),
('Date information', {'fields': ['dtStart','dtEnd']}),
('Auteur', {'fields': ['Author']}),
]
diff --git a/comm_op/models.py b/comm_op/models.py
index 43a9dc2..c04aedd 100644
--- a/comm_op/models.py
+++ b/comm_op/models.py
@@ -1,9 +1,11 @@
from django.db import models
from django.conf import settings
from django.utils import timezone
+import uuid
# Create your models here.
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)
sTitle = models.CharField('Titre', max_length=250)
sDesc = models.TextField('Description')
diff --git a/mycaldav/templates/op/op_view.html b/mycaldav/templates/op/op_view.html
index 0cbbea4..798ca29 100644
--- a/mycaldav/templates/op/op_view.html
+++ b/mycaldav/templates/op/op_view.html
@@ -12,11 +12,10 @@
{% if task.done %}
{{task.key}}
{% else %}
- {{task.key}}
+ {{task.key}}
{% endif %}
- {{task.str_start_date}} - {{task.str_end_date}}
- {{task.str_start_time}} - {{task.str_end_time}}
+ {{task.str_start_date}} {% if task.str_end_date != None %}- {{task.str_end_date}} {% endif %}
{% if task.href != "" %}
diff --git a/mycaldav/views.py b/mycaldav/views.py
index 14ca097..81404df 100644
--- a/mycaldav/views.py
+++ b/mycaldav/views.py
@@ -6,6 +6,7 @@ from django.template import loader
from django.views.decorators.clickjacking import xframe_options_exempt
from django.contrib.auth.decorators import login_required
+
import caldav as cal
from datetime import datetime, timedelta, time
@@ -15,6 +16,20 @@ from datetime import datetime, timedelta, time
from mycaldav.models import *
from mycaldav.settings 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
@@ -37,8 +52,10 @@ def view_task_edit_caldav(request, uuid):
def view_op_edit_caldav(request, uuid):
print(uuid)
- myClient = cls_caldav_client()
- myClient.mark_as_done_task(calandar=myClient.a_op,uuid=uuid)
+ object = comm_opMessage.objects.get(pk=uuid)
+ object.bDone = True
+ object.save()
+
return view_op_caldav(request)
def view_vhc_edit_caldav(request, uuid):
@@ -72,10 +89,23 @@ def view_road_caldav(request):
return HttpResponse(template.render(context, request))
@xframe_options_exempt
def view_op_caldav(request):
- o_caldav = cls_caldav(url=caldav_cfg["op"])
- o_caldav.get_caldav_data(periode=1)
+ o_items = comm_opMessage.objects.filter(bDone=False, dtStart__lte= datetime.today() + timedelta(days=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")
- context = {'latest_task_list': o_caldav.items}
+ context = {'latest_task_list': all_items}
return HttpResponse(template.render(context, request))
@xframe_options_exempt
|