def post(self): m = attrdict(email=u(''), username=u(''), password=u('')) p = attrdict(password=u(''), confirm_password=u('')) if (not self.try_update_model(m) & self.try_update_model(p) or not self.validate(m, credential_validator) & self.validate(m, signup_validator) & self.validate(p, password_match_validator) or not self.create_account(m)): return self.json_errors() return self.json_response({})
def When(): return attrdict({ 'begin': u('') or datetime.today(), 'end': u('') or datetime.today(), 'total_duration': u(''), 'schedules': [] })
def post(self): m = attrdict(username=u(''), password=u('')) if (not self.try_update_model(m) or not self.validate(m, credential_validator) or not self.authenticate(m)): return self.json_errors() return self.json_response({'username': m.username})
def Schedules(): return attrdict({ 'number': u(''), 'description': u(''), 'start': u('') or datetime.today(), 'finish': u('') or datetime.today(), 'duration': u('') })
def __call__(self, request, following): environ = request.environ handler, route_args = self.match(environ['PATH_INFO'].lstrip('/')) environ['route_args'] = attrdict(route_args) if handler is None: if following is not None: return following(request) return None return handler(request)
def create_account(self, r): # TODO samples.users.append(attrdict( first_name='', id=100, last_name='', password=r.password, username=r.username, gravatar_hash='')) return False
def Organization(): return attrdict({ 'number': u(''), 'name': u(''), 'address': u(''), 'city': u(''), 'phone': u(''), 'email': u(''), 'fax': u('') })
def post(self): m = attrdict(slug=u(''), message=u('')) if (not self.try_update_model(m, self.route_args) or not self.try_update_model(m) or not self.validate(m, post_comment_validator) or not self.add_post_comment(m)): return self.json_errors() r = self.json_response({}) r.status_code = 201 return r
def Costs(): return attrdict({ 'contribution': u(''), 'pktmoney': u(''), 'other_cost': u(''), 'total': u(''), 'tax': u(''), 'brutto': u(''), 'netto': u('') })
def Personal(): return attrdict( { 'number': u(''), 'name': u(''), 'nip': u(''), 'group': u(''), 'position': u(''), 'unit_wkplaces': u(''), 'main_wkplaces': u('') })
def Training(**other): return attrdict( { 'number': u(''), 'recorded': u(''), 'title': u(''), 'category': u(''), 'description': u(''), 'operator': Organization(), 'when': When(), 'where': Organization(), 'participants': Participants(), 'costs': Costs() }, **other)
def get(self): m = attrdict(slug=u(''), fields=['']) if (not self.try_update_model(m, self.route_args) or not self.try_update_model(m, self.request.query) or not self.validate(m, post_spec_validator)): return self.json_errors() p = self.get_post(m.slug, m.fields) if not p: return not_found() r = self.json_response(p) if self.principal: r.cache_dependency = ( keys.post(m.slug), keys.author_comments(self.principal.id)) else: r.cache_dependency = (keys.post_public(m.slug),) return r
def model(self): return attrdict({ 'password': u(''), 'confirm_password': u(''), 'question_id': '1' })
def get(self): m = attrdict(q=u(''), page=0) if (not self.try_update_model(m, self.request.query) or not self.validate(m, search_posts_validator)): return self.json_errors() return self.json_response(self.search_posts(m.q, m.page))
def model(self): return attrdict({'message': '', 'turing_number': ''})
def Participants(): return attrdict({ 'total': u(''), 'peserta': [] })
def authenticate(self, username): u = _.first(samples.users, lambda u: u.username == username) if not u: return None return attrdict(id=u.id, password=u.password)
def get_user(self, user_id): u = find_user_by_id(int(user_id)) if not u: return None return attrdict(id=str(u.id), username=u.username)
def model(self): return attrdict({ 'username': u(''), 'remember_me': False })