コード例 #1
0
ファイル: app.py プロジェクト: marissashen/sofc
def treasurerUpdateAppeal(sofc, costID):
    conn = dbconn2.connect(DSN)

    if 'CAS_USERNAME' in session:
        username = session['CAS_USERNAME']
        deadline = session['deadline']
        orgName = T.orgSOFC(conn, sofc)
        treasurer = T.isTreasurerOrg(conn, username, orgName)
        date = datetime.datetime.now()
        canEdit = date <= deadline
        if treasurer:
            costID = int(costID)
            eventID = T.getEventID(conn, costID)
            act = request.form['submit']
            if act == "update":
                explanation = request.form['explanation']
                pdf = request.form.get('pdf', None)
                T.updateAppeal(conn, username, costID, explanation, pdf)
            elif act == "delete":
                T.deleteAppeal(conn, username, costID)
                eventID = T.getEventID(conn, costID)
            return redirect(
                url_for('treasurerEvent', sofc=sofc, eventID=eventID))
    else:
        return redirect(url_for('login'))
コード例 #2
0
ファイル: app.py プロジェクト: marissashen/sofc
def treasurerEvent(sofc, eventID):
    conn = dbconn2.connect(DSN)

    if 'CAS_USERNAME' in session:
        username = session['CAS_USERNAME']
        deadline = session['deadline']
        orgName = T.orgSOFC(conn, sofc)
        treasurer = T.isTreasurerOrg(conn, username, orgName)
        date = datetime.datetime.now()
        canEdit = date <= deadline
        if treasurer:
            sofc = int(sofc)
            eventID = int(eventID)
            oldEventName = T.getName(conn, eventID)
            act = request.form['submit']

            # update event
            if act == "update":
                eventName = request.form['eventName']
                purpose = request.form['purpose']
                eType = request.form['eType']
                eventDate = request.form['eventDate']
                students = request.form['students']
                T.updateEvent(conn, username, eventID, orgName, oldEventName,
                              eventName, purpose, eventDate, deadline, eType,
                              students)
                return displayTreasurerEvent(sofc, eventID)
            # delete event
            elif act == "delete":
                T.deleteEvent(conn, orgName, eventID)
                return redirect(url_for('treasurerOrg', sofc=sofc))
            # add a new cost to an existing event
            elif act == "cost":
                return redirect(
                    url_for('treasurerCost', sofc=sofc, eventID=eventID))
            # edit an existing cost
            elif act[:3] == "edc":
                costID = int(act[4:])
                return redirect(
                    url_for(
                        'treasurerUpdateCost',
                        sofc=sofc,
                        eventID=eventID,
                        costID=costID,
                    ))
            # add a new appeal to an existing cost
            elif act[:3] == "add":
                costID = int(act[4:])
                return redirect(
                    url_for('treasurerAppeal', sofc=sofc, costID=costID))
            # edit an existing appeal
            elif act[:3] == "eda":
                costID = int(act[4:])
                return redirect(
                    url_for('treasurerUpdateAppeal', sofc=sofc, costID=costID))
    else:
        return redirect(url_for('login'))
コード例 #3
0
ファイル: app.py プロジェクト: marissashen/sofc
def displayTreasurerUpdateAppeal(sofc, costID):
    conn = dbconn2.connect(DSN)

    if 'CAS_USERNAME' in session:
        username = session['CAS_USERNAME']
        deadline = session['deadline']
        orgName = T.orgSOFC(conn, sofc)
        treasurer = T.isTreasurerOrg(conn, username, orgName)
        date = datetime.datetime.now()
        canEdit = date <= deadline
        if treasurer:
            costID = int(costID)
            info = T.getNameCTypeUpdate(conn, costID)
            return render_template('treasurerUpdateAppeal.html',
                                   canEdit=canEdit,
                                   info=info)
    else:
        return redirect(url_for('login'))
コード例 #4
0
ファイル: app.py プロジェクト: marissashen/sofc
def displayTreasurerCost(sofc, eventID):
    conn = dbconn2.connect(DSN)

    if 'CAS_USERNAME' in session:
        username = session['CAS_USERNAME']
        deadline = session['deadline']
        orgName = T.orgSOFC(conn, sofc)
        treasurer = T.isTreasurerOrg(conn, username, orgName)
        date = datetime.datetime.now()
        canEdit = date <= deadline
        if treasurer:
            sofc = int(sofc)
            eventName = T.getName(conn, eventID)
            return render_template('treasurerCost.html',
                                   canEdit=canEdit,
                                   eventName=eventName)
    else:
        return redirect(url_for('login'))
コード例 #5
0
ファイル: app.py プロジェクト: marissashen/sofc
def treasurerUpdateCost(sofc, eventID, costID):
    conn = dbconn2.connect(DSN)

    if 'CAS_USERNAME' in session:
        username = session['CAS_USERNAME']
        deadline = session['deadline']
        orgName = T.orgSOFC(conn, sofc)
        treasurer = T.isTreasurerOrg(conn, username, orgName)
        date = datetime.datetime.now()
        canEdit = date <= deadline
        if treasurer:
            costID = int(costID)
            eventID = int(eventID)
            act = request.form['submit']
            if act == "update":
                total = request.form['total']
                if cType == "Attendee":
                    pdf = request.form['pdf']
                    args = [pdf]
                elif cType == "Food":
                    explanation = request.form['explanation']
                    args = [explanation]
                elif cType == "Formula":
                    kind = request.form['kind']
                    input = request.form['input']
                    pdf = request.form['pdf']
                    args = [kind, input, pdf]
                elif cType == "Honorarium":
                    name = request.form['name']
                    contract = request.form['contract']
                    args = [name, contract]
                elif cType == "Supply":
                    pdf1 = request.form['pdf1']
                    pdf2 = request.form['pdf2']
                    pdf3 = request.form['pdf3']
                    args = [pdf1, pdf2, pdf3]
                T.updateCost(conn, username, costID, total, args)
            elif act == "delete":
                T.deleteCost(conn, username, costID)
            return redirect(
                url_for('treasurerEvent', sofc=sofc, eventID=eventID))
    else:
        return redirect(url_for('login'))
コード例 #6
0
ファイル: app.py プロジェクト: marissashen/sofc
def displayTreasurerEvent(sofc, eventID):
    conn = dbconn2.connect(DSN)

    if 'CAS_USERNAME' in session:
        username = session['CAS_USERNAME']
        deadline = session['deadline']
        orgName = T.orgSOFC(conn, sofc)
        treasurer = T.isTreasurerOrg(conn, username, orgName)
        date = datetime.datetime.now()
        canEdit = date <= deadline
        if treasurer:
            event = G.eventInfo(conn, eventID)
            costList = G.eventCosts(conn, eventID)
            costAppealList = G.eventCostsAppeals(conn, eventID)
            return render_template('treasurerEvent.html',
                                   canEdit=canEdit,
                                   event=event,
                                   costList=costList,
                                   costAppealList=costAppealList)
    else:
        return redirect(url_for('login'))
コード例 #7
0
ファイル: app.py プロジェクト: marissashen/sofc
def treasurerOrg(sofc):
    conn = dbconn2.connect(DSN)

    if 'CAS_USERNAME' in session:
        username = session['CAS_USERNAME']
        deadline = session['deadline']
        orgName = T.orgSOFC(conn, sofc)
        treasurer = T.isTreasurerOrg(conn, username, orgName)
        funding = T.getFunding(conn, deadline)
        date = datetime.datetime.now()
        canEdit = date <= deadline
        if treasurer:
            act = request.form['submit']

            # edit event (also add costs & appeals)
            if act[:4] == "edit":
                eventID = int(act[5:])
                return redirect(
                    url_for('treasurerEvent', sofc=sofc, eventID=eventID))
            # purposefully change deadline
            if act == "change":
                fundingDeadline = request.form['fundingDeadline']
                session['deadline'] = fundingDeadline
            # add a new event
            if act == "event":
                fundingDeadline = funding['deadline']
                eventName = request.form['eventName']
                purpose = request.form['purpose']
                eType = request.form['eType']
                eventDate = request.form['eventDate']
                students = request.form['students']
                message = T.addEvent(conn, username, orgName, eventName,
                                     purpose, eventDate, fundingDeadline,
                                     eType, students)
                if message[0:2] == "An":
                    pass
            return displayTreasurerOrg(sofc)
    else:
        return redirect(url_for('login'))
コード例 #8
0
ファイル: app.py プロジェクト: marissashen/sofc
def displayTreasurerOrg(sofc):
    conn = dbconn2.connect(DSN)

    if 'CAS_USERNAME' in session:
        username = session['CAS_USERNAME']
        deadline = session['deadline']
        funding = T.getFunding(conn, deadline)
        orgName = T.orgSOFC(conn, sofc)
        treasurer = T.isTreasurerOrg(conn, username, orgName)
        date = datetime.datetime.now()
        canEdit = date <= deadline
        if treasurer:
            deadlineList = G.allDeadlines(conn)
            eventList = G.allEventsNow(conn, orgName, deadline)
            return render_template('treasurerOrg.html',
                                   canEdit=canEdit,
                                   username=username,
                                   orgName=orgName,
                                   funding=funding,
                                   deadlineList=deadlineList,
                                   eventList=eventList)
    else:
        return redirect(url_for('login'))
コード例 #9
0
ファイル: app.py プロジェクト: marissashen/sofc
def treasurerCost(sofc, eventID):
    conn = dbconn2.connect(DSN)

    if 'CAS_USERNAME' in session:
        username = session['CAS_USERNAME']
        deadline = session['deadline']
        orgName = T.orgSOFC(conn, sofc)
        treasurer = T.isTreasurerOrg(conn, username, orgName)
        date = datetime.datetime.now()
        canEdit = date <= deadline
        if treasurer:
            eventID = int(eventID)
            if request.form['submit'] == "add":
                total = request.form['total']
                cType = request.form['cType']
                costID = T.addCost1(conn, username, eventID, total, cType)
                if cType == "Attendee":
                    pdf = request.files['pdf']
                    filename = secure_filename(str(costID) + ".pdf")
                    pathname = "files/" + filename
                    pdf.save(pathname)
                    args = [pathname]
                elif cType == "Food":
                    explanation = request.form['explanation']
                    args = [explanation]
                elif cType == "Formula":
                    kind = request.form['kind']
                    input = request.form['input']
                    pdf = request.form.get('pdf', None)
                    pathname = None
                    if pdf:
                        filename = secure_filename(str(costID) + ".pdf")
                        pathname = "files/" + filename
                        pdf.save(pathname)
                    args = [kind, input, None]
                elif cType == "Honorarium":
                    name = request.form['name']
                    contract = request.files['contract']
                    args = [name, contract]
                elif cType == "Supply":
                    pdf1 = request.files['pdf1']
                    filename1 = secure_filename(str(costID) + "pdf1.pdf")
                    pathname1 = "files/" + filename1
                    pdf1.save(pathname1)
                    pathname2 = None
                    pathname3 = None
                    pdf2 = request.form.get('pdf2', None)
                    if pdf2:
                        filename2 = secure_filename(str(costID) + "pdf2.pdf")
                        pathname2 = "files/" + filename2
                        pdf.save(pathname2)
                    pdf3 = request.form.get('pdf3', None)
                    if pdf3:
                        filename3 = secure_filename(str(costID) + "pdf3.pdf")
                        pathname3 = "files/" + filename3
                        pdf.save(pathname3)
                    args = [pathname1, pathname2, pathname3]
                T.addCost2(conn, costID, cType, args)
                return redirect(
                    url_for('displayTreasurerEvent',
                            sofc=sofc,
                            eventID=eventID))
    else:
        return redirect(url_for('login'))