示例#1
0
 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({})
示例#2
0
def When():
    return attrdict({
        'begin': u('') or datetime.today(),
        'end': u('') or datetime.today(),
        'total_duration': u(''),
        'schedules': []
    })
示例#3
0
 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})
示例#4
0
def Schedules():
    return attrdict({
        'number': u(''),
        'description': u(''),
        'start': u('') or datetime.today(),
        'finish': u('') or datetime.today(),
        'duration': u('')
    })
示例#5
0
 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)
示例#6
0
 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
示例#7
0
def Organization():
    return attrdict({
        'number': u(''),
        'name': u(''),
        'address': u(''),
        'city': u(''),
        'phone': u(''),
        'email': u(''),
        'fax': u('')
    })
示例#8
0
 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
示例#9
0
def Costs():
    return attrdict({
        'contribution': u(''),
        'pktmoney': u(''),
        'other_cost': u(''),
        'total': u(''),
        'tax': u(''),
        'brutto': u(''),
        'netto': u('')
    })
示例#10
0
def Personal():
    return attrdict(
        {
            'number': u(''),
            'name': u(''),
            'nip': u(''),
            'group': u(''),
            'position': u(''),
            'unit_wkplaces': u(''),
            'main_wkplaces': u('')
        })
示例#11
0
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)
示例#12
0
 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
示例#13
0
 def model(self):
     return attrdict({
         'password': u(''),
         'confirm_password': u(''),
         'question_id': '1'
     })
示例#14
0
 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))
示例#15
0
 def model(self):
     return attrdict({'message': '', 'turing_number': ''})
示例#16
0
def Participants():
    return attrdict({
        'total': u(''),
        'peserta': []
    })
示例#17
0
 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)
示例#18
0
 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)
示例#19
0
 def model(self):
     return attrdict({
         'username': u(''),
         'remember_me': False
     })