예제 #1
0
파일: handlers.py 프로젝트: paulftw/utsoac
    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())
예제 #2
0
파일: handlers.py 프로젝트: paulftw/utsoac
 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())
예제 #3
0
파일: handlers.py 프로젝트: paulftw/utsoac
 def activity(self):
     if self.request.args.has_key('activity'):
         return Activity.get_by_key_encoded(
             self.request.args.get('activity'))
     else:
         return None
예제 #4
0
파일: handlers.py 프로젝트: paulftw/utsoac
 def activity(self):
     return Activity.get_by_key_encoded(self.activity_id)
예제 #5
0
파일: handlers.py 프로젝트: paulftw/utsoac
 def activity(self):
   if self.request.args.has_key('activity'):
     return Activity.get_by_key_encoded(self.request.args.get('activity'))
   else:
     return None
예제 #6
0
파일: handlers.py 프로젝트: paulftw/utsoac
 def activity(self):
   return Activity.get_by_key_encoded(self.activity_id)