def post(self): if not self.form.validate(): self.set_message( 'error', 'Invalid activity info. Please fix errors and try again.', flash=True, life=10) return self.get() activity_id = self.form.activity_id.data if (activity_id != None and len(activity_id) > 0): activity = Activity.get_by_key_encoded(activity_id) # Check ownership if (activity.owner != self.auth_current_user.username): self.set_message( 'error', 'Post your own trip and edit it as much as you like!', life=10, flash=True) return redirect('/') else: activity # TODO copy form data to activity else: # New Activity activity = Activity.create(author=self.auth_current_user, **self.form.data) self.set_message('success', 'Activity saved. Let\'s do it!', flash=True, life=10) return redirect('/activity?activity=%s' % activity.key())
def post(self): if not self.form.validate(): self.set_message('error', 'Invalid activity info. Please fix errors and try again.', flash=True, life=10) return self.get() activity_id = self.form.activity_id.data if (activity_id != None and len(activity_id) > 0): activity = Activity.get_by_key_encoded(activity_id) # Check ownership if (activity.owner != self.auth_current_user.username): self.set_message('error', 'Post your own trip and edit it as much as you like!', life=10, flash=True) return redirect('/') else: activity # TODO copy form data to activity else: # New Activity activity = Activity.create(author=self.auth_current_user, **self.form.data) self.set_message('success', 'Activity saved. Let\'s do it!', flash=True, life=10) return redirect('/activity?activity=%s' % activity.key())
def activity(self): if self.request.args.has_key('activity'): return Activity.get_by_key_encoded( self.request.args.get('activity')) else: return None
def activity(self): return Activity.get_by_key_encoded(self.activity_id)
def activity(self): if self.request.args.has_key('activity'): return Activity.get_by_key_encoded(self.request.args.get('activity')) else: return None