def _api_move_or_resize_by_code(user, id, existed, delta, resize, event_id): response_data = {} response_data['status'] = "PERMISSION DENIED" if existed: occurrence = Occurrence.objects.get(id=id) occurrence.end += delta if not resize: occurrence.start += delta if CHECK_OCCURRENCE_PERM_FUNC(occurrence, user): occurrence.save() response_data['status'] = "OK" else: event = Event.objects.get(id=event_id) dts = 0 dte = delta if not resize: event.start += delta dts = delta event.end = event.end + delta if CHECK_EVENT_PERM_FUNC(event, user): event.save() event.occurrence_set.all().update( original_start=F('original_start') + dts, original_end=F('original_end') + dte, ) response_data['status'] = "OK" return response_data
def decorator(request, *args, **kwargs): user = request.user if not user: return HttpResponseRedirect(settings.LOGIN_URL) occurrence, event, calendar = get_objects(request, *args, **kwargs) if calendar and event: allowed = (CHECK_EVENT_PERM_FUNC(event, user) and CHECK_CALENDAR_PERM_FUNC(calendar, user) and CHECK_OCCURRENCE_PERM_FUNC(occurrence, user)) if not allowed: return HttpResponseRedirect(settings.LOGIN_URL) # all checks passed return function(request, *args, **kwargs) return HttpResponseNotFound('<h1>Page not found</h1>')
def decorator(request, *args, **kwargs): user = request.user if not user: return HttpResponseRedirect(settings.LOGIN_URL) occurrence, event, calendar = get_objects(request, *args, **kwargs) if calendar and event: #____________________IN THE WORKS FOR PERMISSIONS CHECKING_____ if event.creator == user: #____________________IN THE WORKS FOR PERMISSIONS CHECKING_____ allowed = (CHECK_EVENT_PERM_FUNC(event, user) and CHECK_CALENDAR_PERM_FUNC(calendar, user) and CHECK_OCCURRENCE_PERM_FUNC(occurrence, user)) #____________________IN THE WORKS FOR PERMISSIONS CHECKING_____ else: # return HttpResponseRedirect('<h1 style="text-align:center">You do not have permission to edit this guides schedule</h1>') return HttpResponseRedirect('/') #____________________IN THE WORKS FOR PERMISSIONS CHECKING_____ if not allowed: return HttpResponseRedirect(settings.LOGIN_URL) # all checks passed return function(request, *args, **kwargs) return HttpResponseNotFound('<h1>Page not found</h1>')