Exemplo n.º 1
0
    def get(self):
        my_user = users.get_current_user()
        profile_template = JINJA_ENVIRONMENT.get_template("templates/nickname.html")
        my_profile = Profile.query().filter(Profile.user_id == my_user.user_id ()).get()

        dict_for_template = {
            'profile': my_profile
        }
        self.response.write(profile_template.render(dict_for_template))
Exemplo n.º 2
0
def force_signup(handler):
    user = users.get_current_user()
    if not user:
        handler.redirect('/login')
        return None
    my_profile = Profile.query().filter(Profile.user_id == user.user_id()).get()
    if not my_profile:
        handler.redirect('/nickname')
    return user, my_profile
Exemplo n.º 3
0
 def post(self):
     my_user = users.get_current_user()
     # We ar assuming the user has a profile at this point
     my_profile = Profile.query().filter(Profile.user_id == my_user.user_id ()).fetch(1)[0]
     the_show_wanted = self.request.get('user-show')
     #put shows into the database
     show_record = Show()
     show_record.show_name = the_show_wanted
     show_record.user = my_profile.key
     show_record.put()
     time.sleep(0.1)
     self.redirect('/profile')
Exemplo n.º 4
0
 def post(self):
     my_user, my_profile = force_signup(self)
     if not my_profile:
         my_profile = Profile()
     my_nickname = self.request.get('nickname')
     my_profile.nickname = my_nickname
     my_profile.user_id = my_user.user_id()
     my_profile.put()
     time.sleep(0.1)
     self.redirect('/')
Exemplo n.º 5
0
    def post(self):
        my_user, my_profile = force_signup(self)
        if not my_profile:
            return

        # We ar assuming the user has a profile at this point
        my_profile = Profile.query().filter(Profile.user_id == my_user.user_id ()).fetch(1)[0]
        the_show_wanted = self.request.get('user-show')
        show_poster = self.request.get('poster_path')
        #put shows into the database
        show_record = Show()
        show_record.show_name = the_show_wanted
        show_record.poster_path = show_poster
        show_record.user = my_profile.key
        show_record.put()
        time.sleep(0.1)
        self.redirect('/list')
Exemplo n.º 6
0
    def get(self):
        my_user, my_profile = force_signup(self)
        if not my_profile:
            return
        friends_template = JINJA_ENVIRONMENT.get_template("templates/friends.html")
        all_shows = Show.query().order(Show.user, Show.show_name).filter(Show.user != my_profile.key).fetch()
        all_profiles = Profile.query().filter(Profile.user_id != my_user.user_id()).order(Profile.user_id, Profile.nickname).fetch()

        shows_mapping = {}

        for profile in all_profiles:
            shows_mapping[profile.key.id()] = {'profile': profile, 'shows': []}

        for show in all_shows:
            user_id = show.user.id()
            shows_mapping[user_id]['shows'].append(show)
        dict_for_template = {
            'shows_mapping': shows_mapping,
        }

        self.response.write(friends_template.render(dict_for_template))
Exemplo n.º 7
0
#!/usr/bin/python

import cgi, LINK_HEADERS, sys, json
sys.path.insert(0, str(LINK_HEADERS.DATABASE_LINK))
from database_class import DB
sys.path.insert(0, str(LINK_HEADERS.MODELS_LINK))
from profile_model import Profile
sys.path.insert(0, str(LINK_HEADERS.DAO_LINK))
sys.path.insert(0, str(LINK_HEADERS.SERVICE_LINK))
from login_dao import Login_dao
from auth_service import Auth

print "Content-Type: text/html\r\n\r\n"

form = cgi.FieldStorage()
username = str(form.getvalue("username"))
passcode = str(form.getvalue("passcode"))
first_name = str(form.getvalue("first_name"))
last_name = str(form.getvalue("last_name"))

profile = Profile(username, passcode, first_name, last_name)

if (Auth().verify(username, passcode) == "False"):
    #If authorization failed, we do not update the user info
    print json.dumps({"status": "Fail"})
else:
    #update information
    Login_dao().update_user(profile)
    print json.dumps({"status": "Success"})
Exemplo n.º 8
0
sys.path.insert(0 , str(LINK_HEADERS.MODELS_LINK))
from profile_model import Profile
sys.path.insert(0 , str(LINK_HEADERS.DAO_LINK))
sys.path.insert(0 , str(LINK_HEADERS.SERVICE_LINK))
from login_dao import Login_dao
from auth_service import Auth

print "Content-Type: text/html\r\n\r\n"

form = cgi.FieldStorage()
username = str(form.getvalue("username"))
old_passcode = str(form.getvalue("old_passcode"))
new_passcode = str(form.getvalue("new_passcode"))
verify_passcode = str(form.getvalue("verify_passcode"))

profile = Profile(username, new_passcode, "", "");
profile.prepare()


if(Auth().verify(username, old_passcode)=="False"):
    print json.dumps({"status":"Fail"})
else:
    Login_dao().update_passcode(profile)
    print json.dumps({"status":"Success"})






        
Exemplo n.º 9
0
#!/usr/bin/python
import cgi, LINK_HEADERS, sys, json
sys.path.insert(0, str(LINK_HEADERS.DATABASE_LINK))
from database_class import DB
sys.path.insert(0, str(LINK_HEADERS.MODELS_LINK))
from profile_model import Profile
sys.path.insert(0, str(LINK_HEADERS.DAO_LINK))
sys.path.insert(0, str(LINK_HEADERS.SERVICE_LINK))
from login_dao import Login_dao
from auth_service import Auth

print "Content-Type: text/html\r\n\r\n"

form = cgi.FieldStorage()
username = str(form.getvalue("username"))
old_passcode = str(form.getvalue("old_passcode"))
new_passcode = str(form.getvalue("new_passcode"))
verify_passcode = str(form.getvalue("verify_passcode"))

profile = Profile(username, new_passcode, "", "")
profile.prepare()

if (Auth().verify(username, old_passcode) == "False"):
    print json.dumps({"status": "Fail"})
else:
    Login_dao().update_passcode(profile)
    print json.dumps({"status": "Success"})