Example #1
0
 def search(self):
     c.title="Search"
     if request.method=="GET":
         return render('search.mako')
     text=request.POST.get('query')
     if text:
         chanels=self.chanel_q.filter(Chanel.name.like(text)).all()
         c.search['results']=chanels
         return render('search.mako')
Example #2
0
 def signin(self):
     if request.method == "GET":
         return render("sign_in.mako")
     email = self.form_result.get("email")
     password = self.form_result.get("password")
     pers = self.person_q.filter_by(email=email, password=md5(password)).first()
     if pers:
         response.set_cookie("email", email)
         response.set_cookie("password", md5(password))
         redirect("/chanel/main")
     return "Invalid user name and/or password %s" % dir
Example #3
0
 def display_messages(self, vars):
     id=session['chanel']['id']
     chanel=self.chanel_q.filter_by(id=id).first()
     users=[x.name for x in chanel.persons]
     c.messages=self.message_q.filter(Message.chanel_id==chanel.id, Message.timestamp>int(vars)).all()
     length=len(c.messages)        
     if length>20:
         c.messages=c.messages[-length:]
     data={}
     data['messages']=render('messages_json.mako')
     data['users']=users
     return json.dumps(data)
Example #4
0
 def chat_route(self, id):
     autorize()
     chanel=self.chanel_q.filter_by(name=id).first()
     if not chanel:
         return 'This chanel does not exist'
     user_id=session.get('person_id')
     if user_id!=None:
         user=self.person_q.filter_by(id=user_id).first()
         user.chanel_id=chanel.id
         Session.commit()
         session['chanel']={'id':chanel.id, 'name':chanel.name}
         session.save()
         c.user['name']=session.get('name')
         chanels=self.chanel_q.filter_by(owner=c.user['name']).all()
         c.user['chanels']=chanels
     c.title='#'+id
     c.chanel=id
     c.timestamp=int(time.time())
     return render('croute.mako')
Example #5
0
 def index(self):
     return render("/new_action.mako")
Example #6
0
 def main(self):
     c.title='Main page'
     c.name=session['name']
     chanels=self.chanel_q.filter_by(owner=c.name).all()
     c.chanels=chanels
     return render('cmain.mako')