def refresh_schedule(request): from django.contrib.auth.models import User try: id, username = request.META['HTTP_X_GOOG_CHANNEL_TOKEN'].split(':') event = Event.objects.get(id=id) except (ValueError, Event.DoesNotExist): return HttpResponse(json.dumps({'result': 'Event not found'}), status=404, content_type='application/json;charset=utf-8') viewutil.merge_schedule_gdoc(event, username) viewutil.tracker_log(u'schedule', u'Merged schedule via push for event {0}'.format(event), event=event, user=User.objects.filter(username=username).first()) return HttpResponse(json.dumps({'result': 'Merged successfully'}), content_type='application/json;charset=utf-8')
def merge_schedule(request,id): if not request.user.has_perm('tracker.sync_schedule'): return tracker_response(request, template='404.html', status=404) try: event = Event.objects.get(pk=id) except Event.DoesNotExist: return tracker_response(request, template='tracker/badobject.html', status=404) try: numRuns = viewutil.merge_schedule_gdoc(event) except Exception as e: return HttpResponse(json.dumps({'error': e.message }),status=500,content_type='application/json;charset=utf-8') return HttpResponse(json.dumps({'result': 'Merged %d run(s)' % numRuns }),content_type='application/json;charset=utf-8')
def merge_schedule(self, request, queryset): if queryset.count() != 1: self.message_user(request, 'Only select one event for this action', level=messages.ERROR) return for event in queryset: numRuns = viewutil.merge_schedule_gdoc(event) self.message_user(request, "%d runs merged for %s." % (numRuns, event.name)) viewutil.tracker_log(u'schedule', u'Merged schedule for event {0}'.format(event), event=event, user=request.user) for event in queryset: result = event.start_push_notification(request) if result == True: self.message_user(request, 'Push notification started for %s.' % event.name) elif result: return result