def get(self): eventid = self.request.uri.split('/')[-1] event = DBEvent.get_by_id(int(eventid)) if not super(EventInfo, self).get(event.userid): return users = db.GqlQuery("SELECT * FROM DBEventAnketa WHERE eventid = :eventid", eventid = event.key().id()) user_list = [] for user in users: user_list.append({ 'id' : int(user.userid), 'login' : DBUser().get_login_by_id(int(user.userid)), 'name' : user.name.encode("utf8"), 'surname' : user.surname.encode("utf8"), 'phone' : user.phone.encode("utf8"), }) user_list = sorted(user_list, key=lambda user_list: user_list['surname']) self.insertMenu() self.insertTemplate("tpl_event_info.html", { 'user_list' : user_list, 'event' : { 'name' : event.name.encode("utf8"), 'id' : event.key().id(), }, }) self.drawPage(event.name.encode("utf8"))
def get(self): self.checkSession(self.request.headers.get('Cookie')) """ Show all msg captions """ signed_events = db.GqlQuery("SELECT * FROM DBEventAnketa WHERE userid=:userid ORDER BY eventid", userid = self.Session['userid']) # signed_events = db.Query(DBEventAnketa) # signed_events.filter('userid =', self.Session['userid']) # signed_events.order('eventid') self.insertMenu() self.insertTemplate('tpl_events_menu.html') self.insertContent('<h1>Вы подписались на события:</h1>') #found_events = False eventlist = '' for signed_event in signed_events: #if not found_events: found_events = True try: this_event = DBEvent.get_by_id(int(signed_event.eventid)) eventlist += '<a href="/event/'+str(this_event.key().id())+'">'+this_event.name.encode("utf8")+'</a>' users = db.GqlQuery("SELECT * FROM DBEventAnketa WHERE eventid = :eventid", eventid = this_event.key().id()) eventlist += ' [ <i><a href="/event/info/' + str(this_event.key().id()) + '">Участников зарегистрировано: ' + str(users.count()) + '</i></a> ]<br>' except: continue if eventlist != '': self.insertTemplate('tpl_event_add.html', { 'eventlist': eventlist }) else: self.insertContent("Нет ни одного события, на которое вы подписались!") self.drawPage()
def get(self): """ Show all msg captions """ self.checkSession(self.request.headers.get('Cookie')) self.insertMenu() temp_uri = self.request.uri uri = temp_uri.split('/') event_id = int(uri[-1]) event = DBEvent.get_by_id(event_id) if self.Session['access'] >= event.access or int( self.Session['userid']) == int(event.userid): access = '' for an in self.accessNames: access += "<option " try: if int(event.access) == an['access']: access += "selected " except: pass access += "value=" + str(an['access']) + ">" + str( an['name']) + "</option>\n" ec = DBEventCat() cats = ec.get_categories() self.insertTemplate( 'tpl_event_add.html', { 'caption': 'Изменить событие', 'name': event.name.encode("utf8"), 'admin': True, 'day': str(event.date.day ), # event.date.encode("utf8") if event.date else '' 'month': str(event.date.month), 'year': str(event.date.year), 'time': event.time.encode("utf8") if event.time else '', 'place': event.place.encode("utf8") if event.place else '', 'owner': event.owner.encode("utf8") if event.owner else '', 'access': access, 'cats': cats, 'catid': event.catid, 'editor': self.insertFckEdit('descr', event.descr.encode("utf8"), 'Admin'), }) else: self.insertContent('У вас нет прав на изменение этого события') self.drawPage()
def get(self): id = int(self.request.uri.split('/')[-1]) try: event = DBEvent.get_by_id(id) except: self.showMessage("Событие на найдено!") return if not super(EventMailFeed, self).get(event.userid): return self.insertMenu() self.insertTemplate("tpl_message.html", {'ckeditor': self.insertFckEdit("content")}) self.drawPage()
def get(self): """ Show all msg captions """ #self.checkSession(self.request.headers.get('Cookie')) # getting event_id event_id = 0 try: event_id = int(self.request.uri.split('/')[-1]) except: self.redirect('/page_not_found') # # geting pic # pic = db.GqlQuery("SELECT * FROM EventPicture where eventid = :eventid", # eventid = event_id) event = DBEvent.get_by_id(event_id) if not event: self.redirect('/page_not_found') self.checkSession(self.request.headers.get('Cookie'), False) self.insertMenu() # print event.closed if self.Session['access'] >= event.access or int( self.Session['userid']) == int( event.userid) or int(event.access) <= 0: #tpl_cust = template.Template ("""<a href=\"" + self.paramByName("url") + "/event/reg/{{ event_id }}">Регистрация на мероприятие</a>""") self.insertTemplate( 'tpl_event_view.html', { 'event_id': str(event_id), 'event_name': event.name.encode("utf8"), 'event_descr': event.descr.encode("utf8"), 'date': str(event.date) if event.date else '', 'time': event.time.encode("utf8") if event.time else '', 'place': event.place.encode("utf8") if event.place else '', 'owner': event.owner.encode("utf8") if event.owner else '', 'register': "<a href='/event/reg/%i'>Регистрация на мероприятие</a>" % event_id if (event.date >= db.datetime.date.today() and event.closed != True) else False }) self.insertComments(event.key()) else: self.insertContent("У вас нет прав на просмотр этого события") self.drawPage(event.name.encode("utf8"))
def post(self): self.checkSession(self.request.headers.get('Cookie')) self.insertMenu() temp_uri = self.request.uri uri = temp_uri.split('/') event_id = int(uri[-1]) event = DBEvent.get_by_id(event_id) data = self.request.get("pic") if self.checkAccess('eventedit'): if data: try: dbQuery = DBEventPicture.gql("WHERE eventid = :dbeventid", dbeventid=int(event_id)) pics = dbQuery.fetch(1) pic = pics[0] avatar = images.resize(data, 400, 400) pic.image = db.Blob(avatar) pic.put() except: pict = DBEventPicture() avatar = images.resize(data, 400, 400) pict.image = db.Blob(avatar) pict.eventid = int(event_id) pict.put() if self.Session['access'] >= event.access or int( self.Session['userid']) == int(event.userid): event.name = self.request.get('name') event.descr = self.request.get('descr') day = int(self.request.get('day')) month = int(self.request.get('month')) year = int(self.request.get('year')) event.date = db.datetime.date(year, month, day) event.time = self.request.get('time') event.place = self.request.get('place') event.access = int(self.request.get('access')) event.owner = self.request.get('owner') # print self.request.get('closed') if self.request.get('closed') == 'True': event.closed = True else: event.closed = False event.put() self.insertContent('Данные успешно изменены') else: self.insertContent('У вас нет прав на изменение этого события') else: self.insertContent('У вас нет прав на изменение этого события') self.drawPage()
def post(self): self.checkSession(self.request.headers.get('Cookie')) self.insertMenu() temp_uri = self.request.uri uri = temp_uri.split('/') event_id = int(uri[-1]) event = DBEvent.get_by_id(event_id) data = self.request.get("pic") if self.checkAccess('eventedit'): if data: try: dbQuery = DBEventPicture.gql("WHERE eventid = :dbeventid", dbeventid = int(event_id)) pics = dbQuery.fetch(1) pic = pics[0] avatar = images.resize(data, 400, 400) pic.image = db.Blob(avatar) pic.put() except: pict = DBEventPicture() avatar = images.resize(data, 400, 400) pict.image = db.Blob(avatar) pict.eventid = int(event_id) pict.put() if self.Session['access'] >= event.access or int(self.Session['userid']) == int(event.userid): event.name = self.request.get('name') event.descr = self.request.get('descr') day = int(self.request.get('day')) month = int(self.request.get('month')) year = int(self.request.get('year')) event.date = db.datetime.date(year,month,day) event.time = self.request.get('time') event.place = self.request.get('place') event.access = int(self.request.get('access')) event.owner = self.request.get('owner') # print self.request.get('closed') if self.request.get('closed') == 'True': event.closed = True else: event.closed = False event.put() self.insertContent('Данные успешно изменены') else: self.insertContent('У вас нет прав на изменение этого события') else: self.insertContent('У вас нет прав на изменение этого события') self.drawPage()
def post(self): #@todo: Test it on GAE id = int(self.request.uri.split('/')[-1]) try: self.event = DBEvent.get_by_id(id) except: self.showMessage("Событие на найдено!") return if not super(EventMailFeed, self).get(self.event.userid): return message_handler = Handler() anketas = DBEventAnketa.gql("where eventid = :eventid", eventid=id) user_list = [] for anketa in anketas: user_list.append(DBUser.get_by_id(anketa.userid)) message_handler.send(self.Session['user_key'], user_list, ("""Новая информация о событии %s""" % self.event.name.encode("utf-8")).decode("utf-8"), self.request.get('content')) #sender.send_msg_mass(self.event.userid, recipients, self.request.get('content'), db.Text("Новая информация о событии " + self.event.name.encode("utf8"), "utf_8")) self.showMessage("Готово")
def get(self): """ Show all msg captions """ self.checkSession(self.request.headers.get('Cookie'), False) self.insertMenu() eventid = int(self.request.uri.split('/')[-1]) event = DBEvent.get_by_id(eventid) if self.Session['authorized']: users = db.GqlQuery("SELECT * FROM DBEventAnketa WHERE eventid = :eventid AND userid = :userid", eventid = eventid, userid = self.Session['userid']) if users.count() == 0: self.insertTemplate('tpl_reg_on_event.html', {'name' : self.Session['name'], 'surname' : self.Session['surname'], 'email' : self.Session['email'].encode("utf8"), 'event_name' : event.name.encode("utf8"), }) else: self.insertContent("Вы уже зарегистрировались на данное мероприятие!") else: self.insertTemplate('tpl_reg_on_event.html', { 'event_name' : event.name.encode("utf8"), }) self.drawPage(event.name.encode("utf8"))
def get(self): """ Show all msg captions """ #self.checkSession(self.request.headers.get('Cookie')) # getting event_id event_id = 0 try: event_id = int(self.request.uri.split('/')[-1]) except: self.redirect('/page_not_found') # # geting pic # pic = db.GqlQuery("SELECT * FROM EventPicture where eventid = :eventid", # eventid = event_id) event = DBEvent.get_by_id(event_id) if not event: self.redirect('/page_not_found') self.checkSession(self.request.headers.get('Cookie'), False) self.insertMenu() # print event.closed if self.Session['access'] >= event.access or int(self.Session['userid']) == int(event.userid) or int(event.access) <= 0: #tpl_cust = template.Template ("""<a href=\"" + self.paramByName("url") + "/event/reg/{{ event_id }}">Регистрация на мероприятие</a>""") self.insertTemplate('tpl_event_view.html', { 'event_id' : str(event_id), 'event_name' : event.name.encode("utf8"), 'event_descr' : event.descr.encode("utf8"), 'date' : str(event.date) if event.date else '', 'time' : event.time.encode("utf8") if event.time else '', 'place' : event.place.encode("utf8") if event.place else '', 'owner' : event.owner.encode("utf8") if event.owner else '', 'register' : "<a href='/event/reg/%i'>Регистрация на мероприятие</a>" % event_id if (event.date >= db.datetime.date.today() and event.closed != True) else False }) self.insertComments(event.key()) else: self.insertContent("У вас нет прав на просмотр этого события") self.drawPage(event.name.encode("utf8"))
def get(self): self.checkSession(self.request.headers.get('Cookie'), False) spe_news = self.get_news() th = TagHandler() tags = th.get_tags() events = memcache.get("events4main") if not events: events = [] db_events = DBEvent.gql("where date >= :today", today = db.datetime.date.today()) for event in db_events: if event.access <= self.Session['access']: events.append( {'date' : event.date, 'name' : event.name, 'descr' : event.descr, 'id' : event.key().id() }) memcache.add("events4main", pickle.dumps(events), 18000) else: events = pickle.loads(events) if not events: memcache.add("events4main", "no", 18000) confs = [] try: confs = self.random_from_entity(DBConf, 3) except: pass at = None data = memcache.get('random_top') if data: at = pickle.loads(data) else: at = ArchTop().get_top() random.shuffle(at) memcache.add('random_top', pickle.dumps(at), 50) self.drawMainPage(self.insertScroll(), spe_news, tags, events, confs, at[0:5]) # self.drawPage("Главная страница")
def get(self): """ Show all msg captions """ self.checkSession(self.request.headers.get('Cookie')) self.insertMenu() temp_uri = self.request.uri uri = temp_uri.split('/') event_id = int(uri[-1]) event = DBEvent.get_by_id(event_id) if self.Session['access'] >= event.access or int(self.Session['userid']) == int(event.userid): access = '' for an in self.accessNames: access += "<option " try: if int(event.access) == an['access']: access += "selected " except: pass access += "value=" + str(an['access']) + ">" + str(an['name']) + "</option>\n" ec = DBEventCat() cats = ec.get_categories() self.insertTemplate('tpl_event_add.html', { 'caption' : 'Изменить событие', 'name' : event.name.encode("utf8") , 'admin' : True, 'day' : str(event.date.day), # event.date.encode("utf8") if event.date else '' 'month' : str(event.date.month), 'year' : str(event.date.year), 'time' : event.time.encode("utf8") if event.time else '', 'place' : event.place.encode("utf8") if event.place else '', 'owner' : event.owner.encode("utf8") if event.owner else '', 'access' : access, 'cats' : cats, 'catid' : event.catid, 'editor': self.insertFckEdit('descr', event.descr.encode("utf8"), 'Admin'), }) else: self.insertContent('У вас нет прав на изменение этого события') self.drawPage()
def get(self): self.checkSession(self.request.headers.get('Cookie')) """ Show all msg captions """ signed_events = db.GqlQuery( "SELECT * FROM DBEventAnketa WHERE userid=:userid ORDER BY eventid", userid=self.Session['userid']) # signed_events = db.Query(DBEventAnketa) # signed_events.filter('userid =', self.Session['userid']) # signed_events.order('eventid') self.insertMenu() self.insertTemplate('tpl_events_menu.html') self.insertContent('<h1>Вы подписались на события:</h1>') #found_events = False eventlist = '' for signed_event in signed_events: #if not found_events: found_events = True try: this_event = DBEvent.get_by_id(int(signed_event.eventid)) eventlist += '<a href="/event/' + str(this_event.key().id( )) + '">' + this_event.name.encode("utf8") + '</a>' users = db.GqlQuery( "SELECT * FROM DBEventAnketa WHERE eventid = :eventid", eventid=this_event.key().id()) eventlist += ' [ <i><a href="/event/info/' + str( this_event.key().id( )) + '">Участников зарегистрировано: ' + str( users.count()) + '</i></a> ]<br>' except: continue if eventlist != '': self.insertTemplate('tpl_event_add.html', {'eventlist': eventlist}) else: self.insertContent( "Нет ни одного события, на которое вы подписались!") self.drawPage()
def post(self): """ Write bullshit to DB """ self.checkSession(self.request.headers.get('Cookie')) if not self.checkAccess('eventadd'): self.insertMenu() self.insertContent('У вас нет прав на добавление события') else: event = DBEvent() event.name = self.request.get('name') event.minidescr = self.request.get('minidescr')[:1024] event.descr = self.request.get('descr') event.date = db.datetime.date.today() day = int(self.request.get('day')) month = int(self.request.get('month')) year = int(self.request.get('year')) if day and month and year: event.date = db.datetime.date(year, month, day) event.time = self.request.get('time') event.access = int(self.request.get('access')) event.owner = self.request.get('owner') event.place = self.request.get('place') event.userid = self.Session['userid'] event.author = self.Session['user_key'] event.catid = int(self.request.get('cat')) if self.request.get('closed') == 'True': event.closed = True else: event.closed = False event.put() self.insertMenu() self.insertContent('Событие добавлено') dbevents = db.GqlQuery("SELECT * FROM DBEvent WHERE name = :name", name=event.name) eventid = dbevents.fetch(1)[0].key().id() data = self.request.get("pic") if data: try: dbQuery = DBEventPicture.gql("WHERE eventid = :dbeventid", dbeventid=int(eventid)) pics = dbQuery.fetch(1) pic = pics[0] avatar = images.resize(data, 400, 400) pic.image = db.Blob(avatar) pic.put() except: pict = DBEventPicture() avatar = images.resize(data, 400, 400) pict.image = db.Blob(avatar) pict.eventid = int(eventid) pict.put() self.drawPage()