예제 #1
0
파일: matepage.py 프로젝트: mdmoss/unswmate
def render():
    form = cgi.FieldStorage()
    if 'who' in form:
        user = form['who'].value
    else:
        user = ''

    if 'mood' in form and form['mood'].value == "sad":
        print '<iframe src="http://www.omfgdogs.com/" width="1920" height="1080" frameborder="0"></iframe>'

    data = dict(
        matelist = matelist.get_matelist(user),
        news_pane_contents = news.get_news_pane(user),
        gallery = gallery.get_gallery(user),
        courses_pane_contents = courses.get_courses_pane(user),
        profile_picture = images.get_profile_picture(user),
        controls = mate.get_control_panel(user),
        edit_pane_tab = editor.get_edit_tab(user),
        edit_pane_contents = editor.render(user),
        upload_pane_tab = upload.get_upload_tab(user),
        upload_pane_contents = upload.render(user),
        suggest_pane_tab = suggest.get_suggest_tab(user),
        suggest_pane_contents = suggest.get_suggest_pane(user),
        privacy_pane_tab = privacy.get_privacy_tab(user),
        privacy_pane_contents = privacy.get_privacy_pane(user),
    )

    data.update(privacy.get_user_data(user));

    return tempy.render('matepage.template', data)
예제 #2
0
파일: search.py 프로젝트: mdmoss/unswmate
def render(request):
    searchterm = request['search'].value
    results = search(searchterm)
    if results:
        result_string = render_results(results)
    else:
        result_string = "No Results for " + make_safe(searchterm)

    data = dict(
        search_result = result_string
    )
    
    return tempy.render('search.template', data)
예제 #3
0
파일: homepage.py 프로젝트: mdmoss/unswmate
def render():

    all_users = matedb.get_all_users()
    selection = []

    while len(selection) < 21:
        user = random.choice(all_users)
        all_users.remove(user)
        selection.append(user)

    components = dict(users=userlist.render(selection))

    return tempy.render("homepage.template", components)
예제 #4
0
파일: create.py 프로젝트: mdmoss/unswmate
def do_create(request):

    form_contents = ""

    if token not in request:
        # They've just clicked the new link
        if 'email' not in request:
            # They've just clicked the new link
            form_contents += '<h3>Step 1: Supply a valid email address</h3>'
            form_contents += '<form method="post" action="unswmate.cgi?action=create">'
            form_contents += '<input type="hidden" name="action" value="create">'
            form_contents += '<input type="text" name="email" placeholder="Email" class="input-xlarge">'
            form_contents += '<br />'
            form_contents += '<button type="submit" class="btn">Submit</button>'
            form_contents += '</form>'
        else:

            # They're asking for an email to be sent, that's cool
            email = request['email'].value
            send_signup_email(email)

            form_contents += '<h3>Email sent. Check your inbox!</h3>'
     
    elif 'email' in request and 'username' not in request:
        # Actual Signup Time 
        form_contents = get_signup_form(request['email'].value)

    elif 'email' in request and 'username' in request and 'password' in request and token in request:

        if db.user_exists(request['username'].value) or not safe(request['username'].value):
            form_contents += "That usename is already taken. Try again"
            form_contents += get_signup_form(request['email'].value)
        else:
            # Actually do the account creation
            create_account(request['username'].value, request['password'].value, request['email'].value)
            form_contents += "<p>Account Created. Welcome to UNSW, mate</p>";
            form_contents += '<a href="?who=' + request['username'].value + '"><p>Go to my page</p></a>'

    d = dict (
        form = form_contents
    )

    return tempy.render('create.template', d);
예제 #5
0
파일: mate.py 프로젝트: mdmoss/unswmate
def do_mate(request):

    d = {}
    requester = authbar.get_current_login() 

    if requester and'user' in request:
        
        user = request['user'].value
        if 'token' not in request:

            user_address = db.get_data(user, 'email')
            if user_address == '*****@*****.**':
                csemail.send(user_address, "UNSW Mate request", get_mate_message(user, requester))
            d['message'] = 'Mate request sent. Stay tuned...';
            d['link'] = '?who=' + user
            d['link_message'] = "Return to their page. Stalk mode engage!"

        else :
            # Make a mateship
            db.add_mate(user, requester)
            # This is a bit interesting. The order is actually reversed
            # because it's the other user loading the link
            
            d['message'] = 'Mate added!'
            d['link'] = '?who=' + user
            d['link_message'] = "Go to their page"
    else:
        d['message'] = 'User not found';
        
        if requester:
            d['link'] = '?who=' + requester
            d['link_message'] = "Back to my page..."
        else:
            d['link'] = ''
            d['link_message'] = "Return to UNSWMate"

    return tempy.render('mate.template', d)
예제 #6
0
파일: suggest.py 프로젝트: mdmoss/unswmate
def do_suggest(request):
    user = authbar.get_current_login()

    if not user:
        return ""

    ranked_list = []
    for person, score in get_potential_mates(user).items():
        ranked_list.append((person, score))

    if "page" not in request:
        page = 0
    else:
        page = request["page"].value

    ranked_list.sort(key=lambda pair: pair[1])
    ranked_list.reverse()

    first = int(page) * suggestions_per_page
    last = first + suggestions_per_page

    data = dict(username=user, suggestions="")

    renderlist = []
    for user in ranked_list[first:last]:
        renderlist.append(user[0])

    data["suggestions"] = userlist.render(renderlist)

    if data["suggestions"]:
        data["next_page_link"] = '<a href="?action=suggest&page=' + (str(int(page) + 1)) + '">I need more!</a>'
    else:
        data[
            "next_page_link"
        ] = "There's no more... You need to go outside. Meet some new people. Make some real friends. Go. There's things the internet just can't offer."

    return tempy.render("suggest.template", data)
예제 #7
0
파일: courses.py 프로젝트: mdmoss/unswmate
def render(request):
    course = request["course"].value
    d = {"course": safety.make_safe(course)}
    d["members"] = userlist.render(db.get_course_members(course))

    return tempy.render("courses.template", d)