def devent(request): document = Document.objects.filter(user_id=request.user.id).order_by("-docfile")[:1] # Handle file upload if request.method == "POST": form = EventForm(request.POST, request.FILES) if form.is_valid(): event = Event( user=request.user, snap=request.FILES["snap"], eventtype=request.POST["eventtype"], duration=request.POST["duration"], dresscode=request.POST["duration"], date_event=request.POST["date_event"], description=request.POST["description"], place=request.POST["place"], ) event.save() # Redirect to the document list after POST return redirect("dashboard.views.uevent_detail", pk=event.pk) else: form = EventForm() # A empty, unbound form # Load documents for the list page event = Event.objects.all() # Render list page with the documents and the form return render_to_response( "dashboard/userevent.html", {"event": event, "document": document, "form": form}, context_instance=RequestContext(request), )
def event(request): model = Event,User event = Event.objects.all() document = Document.objects.filter( user_id = request.user.id)[:1] # Handle file upload if request.method == 'POST': form = EventForm(request.POST , request.FILES) if form.is_valid(): event = Event(user=request.user, snap=request.FILES['snap'], eventtype = request.POST['eventtype'],duration = request.POST['duration'],dresscode = request.POST['duration'],date_event = request.POST['date_event'], description = request.POST['description'], place = request.POST['place'],) event.save() # Redirect to the document list after POST return redirect('dashboard.views.event') else: form = EventForm() # A empty, unbound form event = Event.objects.all() # Load documents for the list page # Render list page with the documents and the form return render_to_response( 'dashboard/event.html', { 'event': event,'document':document,'form': form,}, context_instance=RequestContext(request) )
def devent(request): document = Document.objects.filter( user_id=request.user.id).order_by('-docfile')[:1] # Handle file upload if request.method == 'POST': form = EventForm(request.POST, request.FILES) if form.is_valid(): event = Event( user=request.user, snap=request.FILES['snap'], eventtype=request.POST['eventtype'], duration=request.POST['duration'], dresscode=request.POST['duration'], date_event=request.POST['date_event'], description=request.POST['description'], place=request.POST['place'], ) event.save() # Redirect to the document list after POST return redirect('dashboard.views.uevent_detail', pk=event.pk) else: form = EventForm() # A empty, unbound form # Load documents for the list page event = Event.objects.all() # Render list page with the documents and the form return render_to_response('dashboard/userevent.html', { 'event': event, 'document': document, 'form': form }, context_instance=RequestContext(request))
def calendar_newevent(request, project_id = None): project = Project.objects.get(pk=project_id) if request.method == 'POST': form = EventForm(request.POST) if form.is_valid(): title = form.cleaned_data['title'] date_start = form.cleaned_data['date_start'] #logger.debug('date start : %s' % date_start) date_end = form.cleaned_data['date_end'] if date_start != '': dateStart = datetime.strptime(date_start, "%d/%m/%Y %H:%M:%S") #04/01/2013 11:11:45 else: dateStart = None if date_end != '': dateEnd = datetime.strptime(date_end, "%d/%m/%Y %H:%M:%S") else: dateEnd = None color = form.cleaned_data['color'] #logger.debug('all day %s' % form.cleaned_data['all_day']) allday = True if form.cleaned_data['all_day'] == 'true' else False #allday = form.cleaned_data['all_day'] event = Event.objects.create(title=title, date_start=dateStart, date_end=dateEnd, color=color, all_day=allday, project=project) event.save() return HttpResponse(content=json.dumps({'success' : 'success', 'element': jsonifyO(event, ['id','title','date_start','date_end','color','all_day'])}), mimetype='application/json') else: errors = json.dumps(form.errors) return HttpResponse(errors, mimetype='application/json') else: form = EventForm(request) return render_to_response('dashboard/calendar/newevent.html', {'form': form, 'project': project}, context_instance=RequestContext(request))
def event(): form = EventForm() if form.validate_on_submit(): title = form.title.data date = form.date.data committee = form.comittee.data description = form.description.data event = Event(title, date, description, committee) db.session.add(event) db.session.commit() return redirect(url_for('admin')) return render_template('dashboard/event.html', form = form)