def get(self,event_id): event = CEvent(event_id).get() user = users.get_current_user() if user and event: if user in event.organizers or users.is_current_user_admin(): event.delete() return self.redirect("/event/edit")
def show(self,event_id): self.template = 'register_success' event = CEvent(event_id).get() if not event: return self.redirect("/events") self.values['event'] = event # is the event using external registration? if event.register_url: return self.redirect(str(event.register_url)) user = users.get_current_user() # check if user is already registered if not user: return self.redirect(users.create_login_url("/events")) # is user not yet registered? if user not in event.participants: if len(event.participants) >= event.register_max: self.template = 'register_full' else: # add user to participants event.participants.append(user) # invalidate event CEvent.remove_from_cache(event.key())
def show_post(self): self.values['current_navigation'] = 'events' form = EventForm(self.request.POST) inEdit = False self.values['form'] = form self.template = 'event_edit' self.values['form_url'] = blobstore.create_upload_url('/event/upload') user = users.get_current_user() if not user: return self.redirect(users.create_login_url("/event/edit")) # special handling: if not admin of application then remove the field # 'approved' if not users.is_current_user_admin(): del form.approved if self.request.get('event') != '': ev = Event.get(self.request.get('event')) if ev is not None and user in ev.organizers or users.is_current_user_admin(): inEdit = True self.values['event'] = ev if form.validate(): # create a new event (will be overwritten if in edit mode) if inEdit: event = ev if ev is not None and ev.approved == True: event.approved = True else: event = Event() event.series_key = self.request.get('series_key') event.gplus_event_url = self.request.get('gplus_event_url') event.external_url = self.request.get('external_url') event.external_width = saveint(self.request.get('external_width')) event.external_height = saveint(self.request.get('external_height')) event.location = self.request.get('location') event.name = self.request.get('name') event.register_url = self.request.get('register_url') if self.request.get('register_max'): event.register_max = saveint(self.request.get('register_max')) else: event.register_max = 0 if event.organizers == []: event.organizers = [user] if users.is_current_user_admin(): event.approved = savebool(self.request.get('approved')) upload_files = self.get_uploads('logo') if len(upload_files) > 0: blob_info = upload_files[0] event.logo = '%s' % blob_info.key() event.status = self.request.get('status') event.agenda = self.request.get_all('agenda') event.start = datetime.strptime(self.request.get('start'), '%Y-%m-%d %H:%M') event.end = datetime.strptime(self.request.get('end'), '%Y-%m-%d %H:%M') event.timezone = float(self.request.get('timezone')) event.agenda_description = self.request.get('agenda_description') event.technologies = self.request.get_all('technologies') event.gdg_chapters = self.request.get('gdg_chapters').split(',') event.organizers = [ users.User(e.strip()) for e in self.request.get('organizers').split(',') ] event.kind_of_support = self.request.get('kind_of_support') event.subdomain = self.request.get('subdomain') event.is_vhackandroid = savebool(self.request.get('is_vhackandroid')) event.put() # time to invalidate the cache CEvent.remove_all_from_cache(event.key()) self.values['event'] = event if inEdit: self.values['modified_successful'] = True else: self.values['created_successful'] = True