def saving_eventable_model(instance, created=False, **kwargs): event = Event( title=instance.get_title(), author=instance.get_author(), to_show=True, ) event.save()
def delete_event(request): event_id = request.POST['event_id'] ret = Event.delete_event_by_id(event_id) if ret.error is not Error.OK: return error_response(ret.error) return response()
def post(self, request, *args, **kwargs): form = NewEventForm(request.POST) if form.is_valid(): #add logic to check for empty marker coordinates, coordinates overlap. if request.POST.get('data'): geo_data = json.loads(request.POST['data']) new_marker = Marker() new_marker.geometry = Point(geo_data['geometry']['coordinates'][1],geo_data['geometry']['coordinates'][0]) new_event = Event() new_event.name= form.cleaned_data['name'] new_event.description = form.cleaned_data['description'] new_event.image = request.FILES.get('image') #image type check #new_event.expiry_date = form.cleaned_data.get('expiry_date') new_event.creator = self.request.user try: new_event.save() new_marker.event = new_event new_marker.save() return HttpResponse('ok') except Exception, e: print e # output exceptions to user else: #output in json return HttpResponse('please place a marker on map')
def post(self, request): if request.session.get('manage', None): session_user = request.session.get('manage', None) user_agent_oop = UserAgents.objects.filter( user=session_user).latest('id') if not user_agent_oop.logout: title_event = request.POST.get("title_event") start_date = request.POST.get("start_date") end_date = request.POST.get("end_date") description = request.POST.get("description") category_identity = request.POST.get("category_identity") if title_event != "" and start_date != "" and end_date != "" and category_identity != "": if category_identity == "0": category_oop = Category.objects.all() else: category_oop = Category.objects.filter( identity=category_identity) if not category_oop.first(): return JsonResponse({'status': 'NotFoundCategory'}) event_oop = Event.objects.filter(title=title_event).first() if not event_oop: for category in category_oop: all_event = Event.objects.all() if all_event.first(): last_event = Event.objects.latest('id').id else: last_event = 0 year = str(datetime.date.today().year) chart = str(chr((last_event % 26) + 65)) id_event = chart + year if Event.objects.filter(identity=id_event).first(): id_event = id_event.lower() start_date = timezone.make_aware( datetime.datetime.strptime( start_date, "%m/%d/%Y")) end_date = timezone.make_aware( datetime.datetime.strptime( end_date, "%m/%d/%Y")) Event(title=title_event, start_date=start_date, end_date=end_date, description=description, identity=id_event, category=category).save() event_oop = Event.objects.filter( title=title_event).first() if event_oop: message = "Done" else: message = "Fail" else: message = "AlreadyExists" else: message = "Empty" return JsonResponse({'status': message}) return HttpResponseRedirect(reverse('Dashboard:login'))
def create_event(request): name = request.POST['name'] end_date = request.POST["end_date"] end_time = request.POST['end_time'] status = request.POST['status'] memo = request.POST['memo'] ret = Event.create_event( name=name, end_date=end_date, end_time=end_time, memo=memo, status=status, ) if ret.error is not Error.OK: return error_response(ret.error) o_event = ret.body return response(body=o_event.to_dict())
def create_user_todo(request): event_id = request.POST['event_id'] ret = get_user_from_session(request) if ret.error is not Error.OK: return error_response(ret.error) o_user = ret.body ret = Event.get_event_by_id(event_id) if ret.error is not Error.OK: return error_response(ret.error) o_event = ret.body ret = UserTodo.create_user_todo( o_user=o_user, o_event=o_event, ) if ret.error is not Error.OK: return error_response(ret.error) o_user_todo = ret.body return response(body=o_user_todo.to_dict())
def top5(self): return Event.get_top_five()
def get_all(self): return Event.all_filter_by_today()
def get_queryset(self): return Event.all_filter_by_today()
def get_all(self): return Event.all_filter_by_week()
def get_queryset(self): return Event.all_filter_by_week()
def get_all(self): return Event.all_filter_by_month()
def get_queryset(self): return Event.all_filter_by_month()
def get_all(self): return Event.get_all()
def get_queryset(self): return Event.get_all()