コード例 #1
0
ファイル: main.py プロジェクト: wasim208/WDLCOMP
def events():
    if (request.method == 'POST'):
        username = session['username']
        eventname = request.form['eventname']
        date = request.form['dateinput']
        stime = request.form['stime']
        etime = request.form['etime']
        descrip = request.form['description']
        eventId = get_random_number()
        con = sqlite3.connect('database.db')
        con.execute(
            "INSERT INTO events (username, eventName, date, startTime, endTime, description, eventId) VALUES (?, ?, ?, ?, ?, ?, ?)",
            (username, eventname, date, stime, etime, descrip, eventId))
        con.commit()
        con.close()
        return redirect(url_for('events'))
    if 'id' in session:
        events = fetchEvents(session['username'])
        frndRequests = fetchFriendRequests(session['username'])
        if (len(frndRequests) > 0):
            return render_template('events.html',
                                   username=session['username'],
                                   e=events,
                                   no=len(events),
                                   tempdate="1234",
                                   alert=len(frndRequests))
        return render_template('events.html',
                               username=session['username'],
                               e=events,
                               no=len(events),
                               tempdate="1234")
    else:
        return redirect('login')
コード例 #2
0
ファイル: main.py プロジェクト: wasim208/WDLCOMP
def home():
    if 'id' in session:
        frndRequests = fetchFriendRequests(session['username'])
        if (len(frndRequests) > 0):
            return render_template('home.html', alert=len(frndRequests))
        return render_template('home.html')
    else:
        return redirect(url_for('login'))
コード例 #3
0
ファイル: main.py プロジェクト: wasim208/WDLCOMP
def tweets():
    if request.method == 'POST':
        global f_name
        username = session['username']
        message = request.form['message']
        posttime = str(datetime.now())[0:19]
        Id = random.randint(0, 9999999999)
        if request.files['fileupload']:
            f = request.files['fileupload']
            f_name = 'static/uploads/' + str(Id) + '.' + f.filename.split(
                '.')[1]
            uploadedIMG = os.path.join(f_name)
            f.save(uploadedIMG)
            f.save(os.path.join(str(Id) + '.' + f.filename.split('.')[1]))
            upload(str(Id) + '.' + f.filename.split('.')[1], 'wdlminiproject')
            os.remove(str(Id) + '.' + f.filename.split('.')[1])
            con = sqlite3.connect('database.db')
            con.execute(
                "INSERT INTO tweets (username, message, postTime, Id, filename) VALUES (?, ?, ?, ?, ?)",
                (username, message, posttime, Id, f_name))
            con.commit()
            con.close()
        else:
            con = sqlite3.connect('database.db')
            con.execute(
                "INSERT INTO tweets (username, message, postTime, Id) VALUES (?, ?, ?, ?)",
                (username, message, posttime, Id))
            con.commit()
            con.close()
    if 'id' in session:
        username = session['username']
        frndRequests = fetchFriendRequests(username)
        tweets = []
        friends = fetchFriends(username)
        friends.append(username)
        now = str(datetime.now())[0:19]
        for i in friends:
            row = fetchTweets(i)
            for j in row:
                j = list(j)
                ago = timeago.format(j[2], now)
                j.append(ago)
                j = [j[2]] + j
                tweets.append(j)
        tweets.sort(reverse=True)
        if (len(frndRequests) > 0):
            print(tweets)
            return render_template('tweets.html',
                                   tweets=tweets,
                                   alert=len(frndRequests))
        return render_template('tweets.html', tweets=tweets)
    return redirect(url_for('home'))
コード例 #4
0
ファイル: main.py プロジェクト: wasim208/WDLCOMP
def notifications():
    if 'id' in session:
        username = session['username']
        friendRequests = fetchFriendRequests(username)
        frndData = []
        for i in friendRequests:
            row = fetchUser(i[0])
            frndData.append(row)
        if (len(frndData) == 0):
            return render_template('notifications.html',
                                   msg="No new friend request")
        return render_template('notifications.html',
                               frndData=frndData,
                               alert=len(friendRequests))
コード例 #5
0
ファイル: main.py プロジェクト: wasim208/WDLCOMP
def profile():
    if 'id' in session:
        username = session['username']
        updateNumEvents(username)
        updateNumFriends(username)
        updateNumTweets(username)
        data = fetchUser(session['username'])
        frndRequests = fetchFriendRequests(session['username'])
        if (len(frndRequests) > 0):
            return render_template('profile.html',
                                   username=session['username'],
                                   data=data[0],
                                   alert=len(frndRequests))
        return render_template('profile.html',
                               username=session['username'],
                               data=data[0])
    return redirect('home')
コード例 #6
0
ファイル: main.py プロジェクト: wasim208/WDLCOMP
def friends():
    if request.method == 'POST':
        username = session['username']
        suser = request.form['suser']
        suserData = fetchUser(suser)
        friends = fetchFriends(username)
        friendsdata = fetchFriendsdata(username)
        frndRequests = fetchFriendRequests(username)
        if (checkRequestExists(username, suser)):
            if (len(frndRequests) > 0):
                return render_template('friends.html',
                                       msg="Request already sent to user",
                                       friends=friendsdata,
                                       alert=len(frndRequests))
            return render_template('friends.html',
                                   msg="Request already sent to user",
                                   friends=friendsdata)
        if (len(suserData) == 0):
            if (len(frndRequests) > 0):
                return render_template('friends.html',
                                       msg="No such user found",
                                       friends=friendsdata,
                                       alert=len(frndRequests))
            return render_template('friends.html',
                                   msg="No such user found",
                                   friends=friendsdata)
        else:
            if suserData[0][0] in friends:
                if (len(frndRequests) > 0):
                    return render_template('friends.html',
                                           msg="User already your friend.",
                                           friends=friendsdata,
                                           alert=len(frndRequests))
                return render_template('friends.html',
                                       msg="User already your friend.",
                                       friends=friendsdata)
            elif suserData[0][0] == username:
                if (len(frndRequests) > 0):
                    return render_template(
                        'friends.html',
                        msg="Find a friend other than yourself.",
                        friends=friendsdata,
                        alert=len(frndRequests))
                return render_template(
                    'friends.html',
                    msg="Find a friend other than yourself.",
                    friends=friendsdata)
            else:
                if (len(frndRequests) > 0):
                    return render_template('friends.html',
                                           msg="User found",
                                           sfriend=suserData,
                                           friends=friendsdata,
                                           alert=len(frndRequests))
                return render_template('friends.html',
                                       msg="User found",
                                       sfriend=suserData,
                                       friends=friendsdata)
    if 'id' in session:
        username = session['username']
        friendsdata = fetchFriendsdata(username)
        frndRequests = fetchFriendRequests(username)
        if (len(frndRequests) > 0):
            return render_template(
                'friends.html',
                msg="Search for friends to connect with them.",
                friends=friendsdata,
                alert=len(frndRequests))
        return render_template('friends.html',
                               msg="Search for friends to connect with them.",
                               friends=friendsdata)
    return render_template('friends.html',
                           msg="Search for friends to connect with them.")