Exemplo n.º 1
0
def update_person_account_access_txn(person_key, account_key, admin):
  key = AccountAccess.key_for(person_key, account_key)
  a = db.get(key)
  if not a:
    a = AccountAccess(key_name=key.name(), person=person_key, account=account_key)
  a.admin = admin
  a.put()
Exemplo n.º 2
0
class SignupHandler(WebHandler):

  @with_new_account
  def get(self, invitation_code):
    self.invitation_code = invitation_code
    self.tabid = 'account-settings-tab'
    if not users.is_current_user_admin():
      if invitation_code == None or len(invitation_code.strip()) == 0:
        self.render_and_finish('account_signup_nocode.html')
      candidate = LimitedBetaCandidate.all().filter('invitation_code', invitation_code).get()
      if candidate == None:
        self.render_and_finish('account_signup_badcode.html')
    if not self.user:
      self.render_and_finish('account_signup_googlenotice.html')

    self.account_form = AccountForm()
    self.render_screen_and_finish()
    
  def render_screen_and_finish(self):
    self.tabid = 'account-settings-tab'
    self.render_and_finish('account_settings.html')

  @with_new_account
  @requires_signup_priv
  def post(self, invitation_code):
    if not users.is_current_user_admin():
      candidate = LimitedBetaCandidate.all().filter('invitation_code', invitation_code).get()
      if candidate == None:
        self.redirect_and_finish('/signup/%s' % invitation_code)
        
    self.account_form = AccountForm(self.request.POST)
    if self.account_form.validate():
      existing_account = Account.all().filter('permalink', self.account.permalink).get()
      if existing_account:
        self.account_form.permalink.errors.append("This name is already taken.")
      else:
        self.account_form.populate_obj(self.account)
        self.account.put()
        if not self.person.is_saved():
          self.person.put()
        self.account_access = AccountAccess(key_name=AccountAccess.key_for(self.person.key(), self.account.key()).name(),
            person=self.person, account=self.account, admin=True)
        self.account_access.put()
        self.redirect_and_finish(u'/%s/products/new/' % self.account.permalink,
          flash = u"Your account has been created. You can add your first product now.")
      
    self.render_screen_and_finish()
Exemplo n.º 3
0
 def post(self, invitation_code):
   if not users.is_current_user_admin():
     candidate = LimitedBetaCandidate.all().filter('invitation_code', invitation_code).get()
     if candidate == None:
       self.redirect_and_finish('/signup/%s' % invitation_code)
       
   self.account_form = AccountForm(self.request.POST)
   if self.account_form.validate():
     existing_account = Account.all().filter('permalink', self.account.permalink).get()
     if existing_account:
       self.account_form.permalink.errors.append("This name is already taken.")
     else:
       self.account_form.populate_obj(self.account)
       self.account.put()
       if not self.person.is_saved():
         self.person.put()
       self.account_access = AccountAccess(key_name=AccountAccess.key_for(self.person.key(), self.account.key()).name(),
           person=self.person, account=self.account, admin=True)
       self.account_access.put()
       self.redirect_and_finish(u'/%s/products/new/' % self.account.permalink,
         flash = u"Your account has been created. You can add your first product now.")
     
   self.render_screen_and_finish()