예제 #1
0
def addBillTrans():
    if 'username' not in session:
        return redirect(url_for('login'))

    print "Well Okay... ^^^^^^^^^^^^^^^^^^^^^"
    groupName = request.args.get('groupName')
    admin = request.args.get('admin')
    lender = request.form['lender']
    receivers = dbHandler.getGroupMemebers(groupName, admin)
    label = request.args.get('label')
    if label:
        pass
    else:
        label = request.form['label']

    dbHandler.delGroupTransForLabel(groupName, admin, label)
    labels = dbHandler.getLabels(groupName, admin)
    for receiver in receivers:
        trans = request.form['n' + receiver[2]]
        if trans == 0:
            continue
        dbHandler.addGroupTrans(groupName, admin, lender,
                                receiver[2], trans, label)

    return redirect(url_for('viewGroup', groupName=groupName, admin=admin, problem=None, labels=labels))
예제 #2
0
def addTrans():
    if 'username' not in session:
        return redirect(url_for('login'))

    username = session['username']
    groupName = request.args.get('groupName')
    admin = request.args.get('admin')
    fro = request.form['fro']
    to = request.form['to']
    amt = request.form['amt']

    friends = dbHandler.getGroupMemebers(groupName, admin)
    flag = 0
    for friend in friends:
        if fro == friend[2]:
            flag = flag + 1
        if to == friend[2]:
            flag = flag + 1

    # if fro == username or to == username:
    #    flag = flag+1
    if fro == to:
        flag = 0

    if flag > 1:
        dbHandler.addGroupTrans(groupName, admin, fro, to, amt)

    return redirect(url_for('viewGroup', admin=admin, groupName=groupName))
예제 #3
0
def index():
    if 'username' in session:
        username = session['username']
        avatar = dbHandler.getProfilePic(username, 100)
        groups = dbHandler.getGroups(username)
        gd = {}
        for i in groups:
            temp = dbHandler.getGroupMemebers(i[0], i[1])
            gd[i] = temp
            groups = gd
        if request.method == 'POST':
            search = request.form['search']
            if search != username:
                result = dbHandler.searchUser(search)
                if result != "No":
                    return redirect(url_for('anotheruser', result=result))
                return render_template('loggedinindex.html', username=username, result=result, groups=gd, avatar=avatar)
        return render_template('loggedinindex.html', username=username, groups=gd, avatar=avatar)
    return render_template('index.html')
예제 #4
0
def addGroupie():
    if 'username' not in session:
        return redirect(url_for('login'))

    groupName = request.args.get('groupName')
    rAddr = request.args.get('rAddr')
    username = session['username']

    if request.method == 'POST':

        memebers = dbHandler.getGroupMemebers(groupName, username)
        add = request.form['add']
        if (groupName, username, add) in memebers:
            return redirect(url_for(rAddr, groupName=groupName, admin=username, problem='memeber'))

        friends = dbHandler.getFriends(username)
        for friend in friends:
            if add == friend[0]:
                dbHandler.addGroupie(groupName, username, add)

        return redirect(url_for(rAddr, groupName=groupName, admin=username))
예제 #5
0
def viewGroup():
    if 'username' not in session:
        return redirect(url_for('login'))

    groupName = request.args.get('groupName')
    admin = request.args.get('admin')
    username = session['username']
    memebers = dbHandler.getGroupMemebers(groupName, admin)
    memebers = [i[2] for i in memebers]
    memebers = sorted(memebers)

    problem = request.args.get('problem')
    temp = dbHandler.getGroupTrans(groupName, admin)
    ctrans = buildCtrans(temp)

    labels = dbHandler.getLabels(groupName, admin)

    labelTrans = {}
    for labl in labels:
        tmp = {}
        tmp['labelTrans'] = dbHandler.getGroupTrans(groupName, admin, labl)
        print tmp
        t = 0
        for j in tmp['labelTrans']:
            t = t + j[5]
        tmp['labelTotal'] = t
        tmp['labelLender'] = tmp['labelTrans'][0][3]
        tmp['labelZeroes'] = []
        for i in memebers:
            flag = 0
            for j in tmp['labelTrans']:
                if i == j[4]:
                    flag = 1

            if not flag:
                tmp['labelZeroes'].append(i)

        print 'bs________________________'
        print labl, tmp['labelZeroes']
        labelTrans[labl] = tmp

    print "labels or kuch bhi"
    print labels
    print labelTrans

    comments = dbHandler.getComment(groupName, admin)
    avatar = dbHandler.getProfilePic(username, 30)
    vertices = comments[1]
    comments = comments[0]

    friends=[i for i in memebers if i != username]
    nonGroupTrans = dbHandler.getGroupTrans(groupName, admin)
    nonGroupTrans = [i for i in nonGroupTrans if i[3]==username or i[4]==username]
    print "^^^^^^^^^^"
    print nonGroupTrans
    indiTrans = {}
    for friend in friends:
        indiTrans[friend[0]] = 0
        print friend[0]
    for group in nonGroupTrans:
        if group[3] in indiTrans.keys():
            indiTrans[group[3]] -= group[5]
        if group[4] in indiTrans.keys():
            indiTrans[group[4]] += group[5]
    print indiTrans
    return render_template('group.html', labels=labels, labelTrans=labelTrans, avatar=avatar, admin=admin, username=username, groupName=groupName, memebers=memebers, problem=problem, indiTrans=indiTrans, trans=temp, comments=comments, vertices=vertices)