コード例 #1
0
ファイル: views.py プロジェクト: dphiggs01/simple-assessment
def index():
    form = StartForm()

    assessment = None
    if 'assessment_id' in session:
        assessment = AssessmentResults.query.get(session['assessment_id'])

    if request.method == 'GET':
        if assessment is not None:
            form.email.data = assessment.resondent_email
        return render_template('0index.html', form=form)

    if form.validate_on_submit():
        if assessment is None:
            assessment = AssessmentResults(assessment_type='Efficiency', resondent_email=form.email.data)
            assessment.sections.append(AssessmentSection('1'))  # Operation
            assessment.sections.append(AssessmentSection('2'))  # Maint
            assessment.sections.append(AssessmentSection('3'))  # Service
            assessment.sections.append(AssessmentSection('4'))  # Info
            assessment.sections.append(AssessmentSection('5'))  # Energy
            db.session.add(assessment)
            db.session.commit()
            session['assessment_id'] = assessment.id
        else:
            assessment.resondent_email = form.email.data
            db.session.add(assessment)
            db.session.commit()
        return redirect(url_for('operational'))

    return render_template('0index.html', form=form)
コード例 #2
0
def start():
    # Get lists for Start page
    project_list = timeclock.get_list("projects")
    task_list = timeclock.get_list("tasks")
    note_list = timeclock.get_list("notes")

    form = StartForm()
    if form.validate_on_submit():
        if "timelogid" in session:
            current_timelog = {
                "userid":
                current_user.userid,
                "timelogid":
                session["timelogid"],
                "projectid":
                session["project"].get("id"),
                "taskid":
                session["task"].get("id"),
                "noteid":
                session["note"].get("id"),
                "start":
                timeclock.convert_timezone(
                    dt.strptime(session["start"], "%Y-%m-%d %H:%M"),
                    "UTC",
                    orig=current_user.timezone).strftime("%Y-%m-%dT%H:%M:%SZ")
            }
            timelog = timeclock.start_timing(form,
                                             current_user,
                                             current_timelog=current_timelog,
                                             stop=1)
        else:
            timelog = timeclock.start_timing(form, current_user)
        if timelog:
            session["timelogid"] = timelog.get("timelogid")
            session["project"] = {
                "id": str(timelog.get("projectid")),
                "name": form.project.data.lower()
            }
            session["task"] = {
                "id": str(timelog.get("taskid")),
                "name": form.task.data.lower()
            }
            session["note"] = {
                "id": str(timelog.get("noteid")),
                "name": form.note.data.lower()
            }
            session["start"] = timeclock.convert_timezone(
                dt.strptime(timelog.get("start"), "%Y-%m-%dT%H:%M:%SZ"),
                current_user.timezone).strftime("%Y-%m-%d %H:%M")
            session.pop("stop", None)
            return redirect(url_for("webtime"))
    return render_template("start.html",
                           title="Start Timing",
                           form=form,
                           projects=project_list,
                           tasks=task_list,
                           notes=note_list)
コード例 #3
0
ファイル: views.py プロジェクト: artooro/emailtogtalk
def retrieve():
    form = StartForm(request.values)
    if form.validate():
        user = users.User(form.email.data)
        q = model.Subscriber.query(model.Subscriber.user == user)
        if q.count() > 0:
            subscriber = q.get()

            mail.send_mail(sender="Email to Gtalk <*****@*****.**>",
                           to=form.email.data,
                           subject="Your Email to Gtalk Info",
                           body="Your gateway email address is %[email protected]" % subscriber.address)

    return "OK"
コード例 #4
0
ファイル: app.py プロジェクト: Qwaz/blind-vote
def start():
    if get_setting('stage') != 'wait':
        return redirect(url_for('index'))
    form = StartForm()

    error = False
    if request.method == 'POST':
        if not form.validate():
            error = '폼을 채워 주세요'
        if form.master.data != get_setting('master'):
            error = '마스터 키가 틀렸어요'
        if not error:
            for key in form.keys.data.split():
                db.session.add(Voters(key))
            set_stage('vote')
            db.session.commit()
            return redirect(url_for('index'))
    return render_template('start.html', form=form, error=error)
コード例 #5
0
ファイル: views.py プロジェクト: artooro/emailtogtalk
def start():
    form = StartForm(request.values)
    if form.validate():
        user = users.User(form.email.data)
        q = model.Subscriber.query(model.Subscriber.user == user)
        if q.count() >= 1:
            return "EXISTS"

        subscriber = model.Subscriber()
        subscriber.user = user

        # Generate address
        address_uuid = uuid.uuid1()
        address = address_uuid.hex
        subscriber.address = address

        subscriber.put()

        # Send user invitation
        xmpp.send_invite(form.email.data)

        return '*****@*****.**' % subscriber.address
    else:
        return "INVALID"
コード例 #6
0
ファイル: app.py プロジェクト: cvickers23/CC-Academic-Planner
def calendar():
    conf = ""

    #cookies
    cookies = request.cookies
    if "courses" in cookies:
        cs = json.loads(cookies.get("courses"))
    else:
        cs = []

    if "credits" in cookies:
        credits = json.loads(cookies.get("credits"))
    else:
        credits = 0
        for i in cs:
            credits += data.getCredits(i["crn"])

    if "modal" in cookies:
        m = json.loads(cookies.get("modal"))
    else:
        m = "first"

    modalform = StartForm()

    form = CourseForm()
    if form.department.data == None:
        form.course.choices = data.getDeptCourses('ALL DEPTS')
    else:
        form.course.choices = data.getDeptCourses(form.department.data)
    form_clear = ClearForm()
    form_remove = RemoveForm()

    ch = []
    #for c in courses:
    for c in cs:
        ch.append((c["crn"], (c["title"] + " " + c["sect"])))
        form_remove.selcourses.choices = ch

    error = None

    #if the form is submitted validly
    if request.method == 'POST':
        if form.validate_on_submit():
            #reformat the form data into a dictionary of course info
            course = fmat(form.course.data)

            #if the course does not conflict with any pre-selected classes, add it to the class schedule
            conflicts = conflict(course, cs)
            if len(conflicts) == 0:
                #courses.append(course)
                cs.append(course)
                form_remove.selcourses.choices.append(
                    (course["crn"], (course["title"] + " " + course["sect"])))
                credits += data.getCredits(course["crn"])

            #if there are one or more conflicts with the current class schedule, do not add it and report conflict
            else:
                conlist = ", ".join(conflicts)
                conf = course["dept"] + " " + course["number"]
                error = 'The selected class, ' + course["title"] + ' (' + ''.join(
                    course["days"]
                ) + ', ' + ''.join(
                    course["times"]
                ) + '),' + ' conflicts with the following courses on your schedule: ' + conlist

        if form_remove.submit.data:
            print(form_remove.selcourses.data)
            for s in form_remove.selcourses.data:
                print(cs)
                for i in cs:
                    if i["crn"] == int(s):
                        print("yes")
                        cs.remove(i)
                        form_remove.selcourses.choices.remove(
                            (int(s), (i["title"] + " " + i["sect"])))
                        credits -= data.getCredits(i["crn"])

        if modalform.start.data:
            if m == "first":
                m = "yes"
            else:
                m = "no"

    attr = []
    for i in cs:
        attr.extend(data.getAttr(i["crn"]))
    attr = ", ".join(list(set(attr)))

    res = make_response(
        render_template('calendar.html',
                        title='Calendar',
                        modalform=modalform,
                        form=form,
                        cform=form_clear,
                        rform=form_remove,
                        error=error,
                        courses=cs,
                        creds=credits,
                        attributes=attr,
                        conf=conf,
                        m=m))
    res.set_cookie("courses", json.dumps(cs))
    res.set_cookie("credits", json.dumps(credits))
    res.set_cookie("modal", json.dumps(m))

    return res