Exemplo n.º 1
0
    def add_site(self):
        self.template_path = 'site_add.html'

        # get the site code
        site_code = self.request.get('site_code').strip()
        self.vars['site_code'] = site_code

        # return if there is no site_code, or we are not a post
        if (not site_code) or self.request.method != 'POST':
            return

        # check that the site_code is valid
        if not Site.is_code_valid(site_code):
            self.vars['site_code_error'] = "site code is not valid"
            return

        # check that the site_code is valid
        if Site.is_code_taken(site_code):
            self.vars['site_code_error'] = "site code already exists"
            return

        # ok to create
        site = Site(site_code=site_code, owner=self.person)
        site.put()

        # create the first shared secret
        SharedSecret.new_for_site(site)

        self.redirect('/site/' + site_code)
Exemplo n.º 2
0
 def add_site(self):
     self.template_path = 'site_add.html'
     
     # get the site code
     site_code = self.request.get('site_code').strip()
     self.vars['site_code'] = site_code
     
     # return if there is no site_code, or we are not a post
     if (not site_code) or self.request.method != 'POST' :
         return
                 
     # check that the site_code is valid
     if not Site.is_code_valid( site_code ):
         self.vars['site_code_error'] = "site code is not valid"
         return
     
     # check that the site_code is valid
     if Site.is_code_taken( site_code ):
         self.vars['site_code_error'] = "site code already exists"
         return
     
     # ok to create
     site = Site( site_code=site_code, owner=self.person )
     site.put()
     
     # create the first shared secret
     SharedSecret.new_for_site( site )
     
     self.redirect('/site/' + site_code )