Ejemplo n.º 1
0
 def createTag(request):
     require_permission(request.user, "Timeline_data.add_tagbase")
     key = request.POST['key']
     languageCode = request.POST['language']
     if TagBase.objects.filter(key=key, language__code=languageCode).count() == 0:
         tag = TagBase()
         tag.key = key
         tag.language = Language.objects.get(code=languageCode)
         tag.save()
         tagVersion = tag.addVersion(request.POST['title'], True)
         return tag
     else:
         raise Exception("Tag with key '%s' already exists for language '%s'" % (key, languageCode))
Ejemplo n.º 2
0
 def createEvent(request):
     require_permission(request.user, "Timeline_data.add_eventbase")
     key = request.POST['key']
     languageCode = request.POST['language']
     if EventBase.objects.filter(key=key, language__code=languageCode).count() == 0:
         event = EventBase()
         event.key = key
         event.language = Language.objects.get(code=languageCode)
         event.save()
         try:
             eventVersion = event.addVersion(request.POST, 'publish' in request.POST)
             return event
         except Exception as e:
             event.delete()
             raise e
     else:
         raise Exception("Event with key '%s' already exists for language '%s'" % (key, languageCode))
Ejemplo n.º 3
0
 def deleteTagVersion(request, tagId, revision):
     require_permission(request.user, "Timeline_data.delete_tagversion")
     tag = EventBase.objects.filter(id=tagId).get()
     if revision is not None:
         tag.deleteVersion(revision)
     return tag
Ejemplo n.º 4
0
 def deleteTag(request, tagId):
     require_permission(request.user, "Timeline_data.delete_tagbase")
     tag = TagBase.objects.filter(id=tagId).get()
     tag.delete()
Ejemplo n.º 5
0
 def updateTag(request, tagId, revision=None):
     tag = TagBase.objects.filter(id=tagId).get()
     version = None
     if request.method == "POST":
         if 'enabled' in request.POST:
             require_permission(request.user, "Timeline_data.change_tagbase")
             tag.toggleEnabled()
         if 'current' in request.POST:
             require_permission(request.user, "Timeline_data.change_tagbase")
             revision = request.POST['current']
             tag.setPublicRevision(revision)
         elif 'save' in request.POST:
             require_permission(request.user, "Timeline_data.add_tagversion")
             version = tag.addVersion(request.POST['title'], False)
         elif 'publish' in request.POST:
             require_permission(request.user, "Timeline_data.add_tagversion")
             version = tag.addVersion(request.POST['title'], True)
         elif 'deleteVersion' in request.POST:
             require_permission(request.user, "Timeline_data.delete_tagversion")
             if revision is None and 'revision' in request.POST:
                 revision = request.POST['revision']
             if revision is not None:
                 tag.deleteVersion(revision)
         elif 'deleteTag' in request.POST:
             require_permission(request.user, "Timeline_data.delete_tagbase")
             tag.delete()
             return (None,None)
     return (tag,version)
Ejemplo n.º 6
0
 def deleteEventVersion(request, eventId, revision):
     require_permission(request.user, "Timeline_data.delete_eventversion")
     event = EventBase.objects.filter(id=eventId).get()
     if revision is not None:
         event.deleteVersion(revision)
     return event
Ejemplo n.º 7
0
 def deleteEvent(request, eventId):
     require_permission(request.user, "Timeline_data.delete_eventbase")
     event = EventBase.objects.filter(id=eventId).get()
     event.delete()
Ejemplo n.º 8
0
 def updateEvent(request, eventId, revision=None):
     event = EventBase.objects.filter(id=eventId).get()
     version = None
     permissions = request.user.get_all_permissions()
     if event is not None and request.method == "POST":
         if 'enabled' in request.POST:
             require_permission(request.user, "Timeline_data.change_eventbase")
             event.toggleEnabled()
             version = event.getCurrentVersion()
         if 'current' in request.POST:
             require_permission(request.user, "Timeline_data.change_eventbase")
             event.setPublicRevision(request.POST['current'])
             version = event.getCurrentVersion()
         elif 'save' in request.POST:
             require_permission(request.user, "Timeline_data.add_eventversion")
             version = event.addVersion(request.POST, False)
         elif 'publish' in request.POST:
             require_permission(request.user, "Timeline_data.add_eventversion")
             version = event.addVersion(request.POST, True)
         elif 'deleteVersion' in request.POST:
             require_permission(request.user, "Timeline_data.delete_eventversion")
             if revision is None and 'revision' in request.POST:
                 revision = request.POST['revision']
             if revision is not None:
                 event.deleteVersion(revision)
         elif 'deleteEvent' in request.POST:
             require_permission(request.user, "Timeline_data.delete_eventbase")
             event.delete()
             return (None,None)
     return (event, version)