예제 #1
0
def student():

    stud_email = session.get('semail')

    form = ComplaintForm()

    if form.validate_on_submit():
        fname = form.fname.data
        email = form.email.data
        date = form.date.data
        degree = form.degree.data
        semester = form.semester.data
        complaintcategory = form.complaintcategory.data
        message = form.message.data
        #file = form.file.data

        db.execute(
            "INSERT INTO complain (fname, email, date, degree, semester, complaintcategory, message) VALUES (:fname, :email, :date, :degree, :semester, :complaintcategory, :message)",
            {
                'fname': fname,
                'email': email,
                'date': date,
                'degree': degree,
                'semester': semester,
                'complaintcategory': complaintcategory,
                'message': message
            })
        db.commit()

        flash('Complaint Registered Successfully.')

        return redirect(url_for('student'))

    return render_template('student.html', form=form)
예제 #2
0
파일: views.py 프로젝트: danrubin/fmt
def index(request):
    """
    A wrapper around ``django.views.generic.date_based.archive_index`` that
    will display an entry form for users to input ``Complaint`` objects.
    """
    
    complaints = Complaint.objects.all()
    
    if request.POST:
        form = ComplaintForm(request.POST)
        if form.is_valid():
            form.save()
    else:
        form = ComplaintForm()
    
    return date_based.archive_index(
        request,
        queryset=complaints,
        date_field='published',
        template_name='complaints/complaint_index.html',
        allow_empty=True,
        extra_context={
            'form': form,
            'total_complaints': len(complaints)
        }
    )
예제 #3
0
def api(request):
    '''
        This view handles all the communications with the Mobile app
    '''
    complaint_form = ComplaintForm(data=request.GET)
    if complaint_form.is_valid():
      submitted=1
      complaint = complaint_form.save(commit=False)
      complaint.status = "submitted"
      complaint.save()
    else:
      submitted=0;
      return HttpResponse("Failed! Please try again later.")
    return HttpResponse("Success!")
예제 #4
0
def submit(request):
    '''
        This view handles all the communications with the Mobile app
    '''
    if request.method == "POST":
      complaint_form = ComplaintForm(data=request.POST)
      if complaint_form.is_valid():
        submitted=1
        complaint = complaint_form.save(commit=False)
        complaint.status = "submitted"
        photo = request.GET.get('photo',None)
        complaint.photo = db.Blob(photo)
        complaint.save()
      else:
        submitted=0;
        return render_to_response("complaintweb.html", locals(), context_instance=RequestContext(request))
      complaint_form = ComplaintForm()
      return render_to_response("complaintweb.html", locals(), context_instance=RequestContext(request))
    else:
      complaint_form = ComplaintForm()
      return render_to_response("complaintweb.html", locals(), context_instance=RequestContext(request))