예제 #1
0
 def put(self):
     if self.middleman_ref:
         middleman = db.Key(self.middleman_ref)
     else:
         middleman = None
     try:
         self.entity.name = self.name
         self.entity.nickname = self.nickname
         self.entity.lastname = self.lastname
         self.entity.introduction = self.introduction
         self.entity.birthday = self.birthday
         self.entity.middleman_ref = middleman
         # parent is needed for building an entity group with LoginUser
         self.entity.parent = self.parent
         self.entity.put()
     except AttributeError:
         # prepare database object for new person
         self.entity = Person(parent=self.parent, owned_by=self.owned_by, name=self.name,
                             lastname=self.lastname,
                             nickname=self.nickname, birthday=self.birthday,
                             introduction=self.introduction, middleman_ref=middleman)
         self.entity.put()
     if not self.parent:
         # generate search keys for contact; cannot run in transaction context
         update_index(self.entity)
     # delete birthday memcache
     memcache.delete('birthdays',namespace=str(self.entity.owned_by.key()))
예제 #2
0
파일: take2edit.py 프로젝트: navimont/take2
    def deattic_contact(self, login_user=None, template_values={}):
        key = self.request.get("key", "")

        contact = Contact.get(key)
        assert contact, "Object key: %s is not a Contact" % (key)
        # access check
        assert contact.owned_by.key() == login_user.key(), "User %s cannot manipulate %s" % (login_user.user.nickname(),str(contact.key()))

        logging.debug("ContactDeattic: %s key: %s" % (contact.name,key))

        contact.attic = False;
        contact.put();
        update_index(contact)

        self.redirect('/editcontact?key=%s' % key)
예제 #3
0
 def put(self):
     try:
         self.entity.adr = self.adr
         self.entity.landline_phone = self.landline_phone
         self.entity.location = location=db.GeoPt(lon=self.lon, lat=self.lat)
         self.entity.location_lock = self.location_lock
         self.entity.map_zoom = self.map_zoom
         self.entity.adr_zoom = self.adr_zoom
         self.entity.put()
     except AttributeError:
         # prepare database object for new person
         self.entity = Address(contact_ref=self.contact_ref, adr=self.adr,
                               landline_phone=self.landline_phone,
                               location=db.GeoPt(lon=self.lon, lat=self.lat), location_lock=self.location_lock,
                               map_zoom=self.map_zoom, adr_zoom=self.adr_zoom)
         self.entity.put()
     update_index(self.entity)
예제 #4
0
    def get(self):
        """processes the signup form"""
        authenticated_user = users.get_current_user()
        login_user = get_login_user()
        template_values = get_current_user_template_values(login_user,self.request.uri)

        # not logged in
        if not authenticated_user:
            self.redirect('/login')
            return

        # already connected
        if login_user and login_user.me:
            self.redirect('/')
            return

        template_values['errors'] = []

        person = PersonBean.edit(None,self.request)
        template_values.update(person.get_template_values())
        err = person.validate()
        terms=self.request.get("terms", None)
        if not terms:
            err.append("You must also acknowledge the terms and conditions.")

        if not err:
            try:
                db.run_in_transaction(initial_user_setup, authenticated_user, person)
            except:
                # an error occured in storing the data
                logging.exception('Transaction failed while storing LoginUser and Person')
                template_values['errors'].append('Database error. Sorry.')
        else:
            template_values['errors'].extend(err)

        if len(template_values['errors']):
            path = os.path.join(os.path.dirname(__file__), "take2welcome.html")
            self.response.out.write(template.render(path, template_values))
            return

        # create search index which is usually done by the PersonBean but not here
        # because the index table is not in the entity group
        update_index(person.entity)

        self.redirect('/')
예제 #5
0
파일: take2edit.py 프로젝트: navimont/take2
    def attic_contact(self, login_user=None, template_values={}):
        key = self.request.get("key", "")

        contact = Contact.get(key)
        assert contact, "Object key: %s is not a Contact" % key
        # access check
        if not write_access(contact, login_user):
            self.error(500)
            return

        logging.debug("ContactAttic: %s key: %s" % (contact.name,key))

        contact.attic = True;
        contact.put();
        update_index(contact)

        # if the contact had a backwards refrence, direkt to the middleman
        if contact.middleman_ref:
            key = str(contact.middleman_ref.key())

        self.redirect('/editcontact?key=%s' % key)
예제 #6
0
파일: take2edit.py 프로젝트: navimont/take2
    def deattic_take2(self, login_user=None, template_values={}):
        instance = self.request.get("instance", "")
        key = self.request.get("key", "")

        t2 = Take2.get(key)
        # consistency checks
        assert t2.class_name() == instance.title(), "Edit class name %s does not fit with object %s" % (instance,key)
        contact = t2.contact_ref
        assert contact.class_name() in ['Person','Contact'], "Object %s key: %s is not a Contact" % (contact.class_name(),str(contact.key()))
        # access check
        if not write_access(contact, login_user):
            self.error(500)
            return

        logging.debug("De-attic: %s instance: %s key: %s" % (contact.name,instance,key))

        t2.attic = False;
        t2.put();
        if t2.class_name() == 'Address':
            update_index(t2)

        self.redirect('/editcontact?key=%s' % str(contact.key()))