Esempio n. 1
0
    def full_render(self, handler,template_file, params={}):
            scheme, netloc, path, query, fragment = urlparse.urlsplit(handler.request.uri)
            administrator = False

            if users.get_current_user():
                url = users.create_logout_url(handler.request.uri)
                url_linktext = 'Sign out'
                if users.is_current_user_admin():
                    administrator = True
            else:
                url = users.create_login_url(handler.request.uri)
                url_linktext = 'Sign in'
            template_params = {
                "current_url": url,
                'user': users.GetCurrentUser(),
                'url': url,
                'url_linktext': url_linktext,
                'administrator': administrator,
                'request': handler.request,
                "user_is_admin": users.is_current_user_admin(),
                "login_url": users.create_login_url(handler.request.uri),
                "logout_url": users.create_logout_url(handler.request.uri),
                "user_gravatar_url":util.getGravatarUrlByUser(users.get_current_user()),
                "user_nickname":util.getUserNickname(users.get_current_user())
            }
            template_params.update(params)
            return template.render(template_file, template_params, True)
Esempio n. 2
0
File: view.py Progetto: honten/diary
    def full_render(self, handler,template_file, params={}):
            scheme, netloc, path, query, fragment = urlparse.urlsplit(handler.request.uri)
            administrator = False
            if users.get_current_user():
                url = users.create_logout_url(handler.request.uri)
                url_linktext = 'Sign out'
                if users.is_current_user_admin():
                    administrator = True
            else:
                url = users.create_login_url(handler.request.uri)
                url_linktext = 'Sign in'
            cpedialog = util.getCPedialog()
            delicious = None
            if cpedialog.delicious_enable:
                delicious = util.getDeliciousTag(cpedialog.delicious_username)
            feeds = None
            if cpedialog.google_ajax_feed_enable:
                feeds = util.getFeedList()
            template_params = {
                "title": cpedialog.title,
                "current_url": url,
                'user': users.GetCurrentUser(),
                'url': url,
                'url_linktext': url_linktext,
                'administrator': administrator,
                'request': handler.request,

                "user_is_admin": users.is_current_user_admin(),
                "login_url": users.create_login_url(handler.request.uri),
                "logout_url": users.create_logout_url(handler.request.uri),
                'logoImages': cpedialog.get_logo_images_list(),
                "BLOG": cpedialog,
                "nav_menus": util.getMenuList(),
                "tags": util.getTagList(),
                "feeds": feeds,
                "delicious": delicious,
                "user_gravatar_url":util.getGravatarUrlByUser(users.get_current_user()),
                "user_nickname":util.getUserNickname(users.get_current_user())
               # "docs": util.getGoogleDocs(config.delicious['username']),
            }
            template_params.update(params)
            return template.render(template_file, template_params, debug=cpedialog.debug)
Esempio n. 3
0
    def full_render(self, handler, template_file, params={}):
        scheme, netloc, path, query, fragment = urlparse.urlsplit(
            handler.request.uri)
        administrator = False

        if users.get_current_user():
            url = users.create_logout_url(handler.request.uri)
            url_linktext = 'Sign out'
            if users.is_current_user_admin():
                administrator = True
        else:
            url = users.create_login_url(handler.request.uri)
            url_linktext = 'Sign in'
        template_params = {
            "current_url":
            url,
            'user':
            users.GetCurrentUser(),
            'url':
            url,
            'url_linktext':
            url_linktext,
            'administrator':
            administrator,
            'request':
            handler.request,
            "user_is_admin":
            users.is_current_user_admin(),
            "login_url":
            users.create_login_url(handler.request.uri),
            "logout_url":
            users.create_logout_url(handler.request.uri),
            "user_gravatar_url":
            util.getGravatarUrlByUser(users.get_current_user()),
            "user_nickname":
            util.getUserNickname(users.get_current_user())
        }
        template_params.update(params)
        return template.render(template_file, template_params, True)
Esempio n. 4
0
def user(user):
    isSelf=False
    if request.method=="GET":
        noUser=False
        if 'user' in session:
            if user==session['user']:
                user=session['user']
                isSelf=True
                #ratings_list=util.getActivitiesAbilityStatic(user)
                #interests_list=util.getActivitiesInterestStatic(user)
        else:
            noUser=True
        return render_template("user.html",address=util.getUserAddress(user),birthday=util.getUserBirthday(user),email=util.getUserEmail(user),gender=util.getUserGender(user),name=util.getUserName(user),nickname=util.getUserNickname(user),phone=util.getUserPhone(user),desire=util.getUserDesire(user),activities=util.getUserActivities(user),user=user,isSelf=isSelf,noUser=noUser)
    else:
        if request.form.has_key("edit"):
            return redirect(url_for("register"))
        if request.form.has_key("save"):
            f = request.form
            data={}
            catChain=""
            for key in f.keys():
                if key == 'catChain':
                    catChain=f[key]
                elif key != 'save':
                    print 'key: ',key
                    s=key.split('_')
                    #print str(s[0])
                    if str(s[0]) not in data:
                        data[str(s[0])]={}
                    data[str(s[0])][str(s[1])]=f[key]
                    #print data
            util.updateActivities(session['user'],data,catChain)
            return render_template("user.html",address=util.getUserAddress(user),birthday=util.getUserBirthday(user),email=util.getUserEmail(user),gender=util.getUserGender(user),name=util.getUserName(user),nickname=util.getUserNickname(user),phone=util.getUserPhone(user),desire=util.getUserDesire(user),activities=util.getUserActivities(user),user=session['user'],isSelf=isSelf)
        if request.form.has_key("desire"):
            return redirect(url_for("desires"))
        if request.form.has_key("my_list"):
            return redirect(url_for("my_list"))
        if request.form.has_key("new_place"):
            return redirect(url_for("new_place"))
Esempio n. 5
0
def register():
    if request.method=="GET":
        if 'user' in session:
            user=session['user']
            if util.getUserGender(user)=="male":
                b=True
            else:
                b=False
            return render_template("register.html",addressline=util.getUserAddressLine(user),addresscity=util.getUserAddressCity(user),addresszipcode=util.getUserAddressZip(user),birthday=util.getUserBirthDay(user),birthmonth=util.getUserBirthMonth(user),birthyear=util.getUserBirthYear(user),email=util.getUserEmail(user),firstname=util.getUserFirstName(user),lastname=util.getUserLastName(user),nickname=util.getUserNickname(user),phone=util.getUserPhone(user),user=user,gender=b)
        return render_template("register.html")
    else:
        if request.form.has_key("submit"):
            if 'user' in session:
                ###incorrect form filling debeugging
                address={'street':request.form['addressline'],'city':request.form['addresscity'],'zipcode':request.form['addresszipcode']}
                birthday=request.form['birthmonth']+''+request.form['birthday']+''+request.form['birthyear']
                name=request.form['firstname']+' '+request.form['lastname']
                util.updateUserInfo(session['user'],address,birthday,request.form['email'],request.form['gender'],name,request.form['phone'],request.form['nickname'])
                return redirect(url_for("user",user=session['user']))
            else:
                user = str(request.form["username"])
                password = str(request.form["pass1"])
                if user == "":
                    return render_template("register.html",nouser=True)
                if password == "":
                    return render_template("register.html",nopassword=True)
                elif password != str(request.form["pass2"]):
                    return render_template("register.html",notmatching=True)
                if util.addUser(user,password):
                    session['user']=user
                    return redirect(url_for("user"))
                else:
                    return render_template("register.html",taken=True)