Example #1
0
	def is_available(self, request_id, offer_id):
		try:
			assert self.current_user, 'Not login'
			uid = self.current_user.key().id()
			rid = force_int(request_id)
			oid = force_int(offer_id)
			request = OneToOnesService.get_request(rid)
			assert request, 'No reqeust found'
			offer = OneToOnesService.get_offer(oid)
			assert offer, 'No offer found'
			
			assert request.author_id == uid or offer.author_id == uid, 'No permission'
		except AssertionError, e:
			logging.error(e)
			return False
Example #2
0
    def _family_values(family):
        """Extract sql row data from family

        Args:
            family (_Family):

        Returns:
            []Object
        """
        return [
            utils.force_int(family.id),
            utils.force_int(family.husband_id),
            utils.force_int(family.wife_id), family.marriage_day,
            family.marriage_month, family.marriage_year, family.marriage_place,
            ""
        ]
Example #3
0
	def decorated_func(arg, *args, **kargs):
		if not arg.is_logged_in:
			arg.add_flash(get_text('LOGIN_REQUIRED'), 'error')
			arg.redirect('/about')
			return
		try:
			assert 'request_id' in kargs and 'offer_id' in kargs, 'Invalid request'
			uid = arg.current_user.key().id()
			rid = force_int(kargs['request_id'])
			oid = force_int(kargs['offer_id'])
			request = OneToOnesService.get_request(rid)
			assert request, 'No reqeust found'
			offer = OneToOnesService.get_offer(oid)
			assert offer, 'No offer found'
		except AssertionError, e:
			logging.error("# %s" % e)
			arg.render_error(404)
			return
Example #4
0
    def _person_values(person):
        """Extract sql row data from person

        Args:
            person (_Person): obj to extract values from

        Returns:
            []Object
        """
        gender = 0
        if person.is_male:
            gender = 1

        return [
            utils.force_int(person.id),
            person.firstname,
            person.surname,
            person.married_name,
            "|".join(person.nicknames),
            "|".join(person.given_names),
            gender,
            person.note,
            utils.force_int(person.childhood_family_id),
            utils.date_to_epoch(person.last_updated),
            person.birth_place,
            person.death_place,
            person.burial_place,
            person.birth_day,
            person.birth_month,
            person.birth_year,
            person.death_day,
            person.death_month,
            person.death_year,
            person.burial_day,
            person.burial_month,
            person.burial_year,
        ]