Esempio n. 1
0
 def validate_name(form, field):
     if is_empty(form.id.data):
         name = Task.query.filter_by(
             user=current_user,
             name=field.data).first()
         if name is not None:
             raise ValidationError('A task with this name already exists.')
Esempio n. 2
0
 def validate_name(form, field):
     if is_empty(form.id.data):
         name = Project.query.filter_by(
             user=current_user,
             company=form.company.data,
             name=field.data).first()
         if name is not None:
             raise ValidationError('A project with this name already exists.')
Esempio n. 3
0
 def validate_project(form, field):
     if is_empty(form.id.data):
         wu = WorkingUnit.query.filter_by(
             user=current_user,
             date=form.date.data,
             project=field.data,
             task=form.task.data).first()
         if wu is not None:
             raise ValidationError('A working time with this project, task and date already exists.')
Esempio n. 4
0
def import_from_json_string(app, string=None):
    if is_empty(string):
        app.logger.error('nothing to import from. abort.')
        return

    content = json.loads(string)

    _users_from_json(app, content)
    _companies_from_json(app, content)
    _projects_from_json(app, content)
    _tasks_from_json(app, content)
    _working_units_from_json(app, content)
Esempio n. 5
0
 def validate_name(self, field, value):
     assert not is_empty(value)
     assert len(value) <= 100
     if g.user:
         self.user = g.user
     return strip(value)
Esempio n. 6
0
 def validate_email(self, field, value):
     assert not is_empty(value), '"%s" may not be empty.' % field
     return strip(value)
Esempio n. 7
0
 def validate_url(self, field, value):
     assert not is_empty(value), '"%s" may not be empty.' % field
     if g.user:
         self.user = g.user
     return strip(value)
Esempio n. 8
0
 def validate_email(form, field):
     if is_empty(form.id.data):
         user = User.query.filter_by(email=field.data).first()
         if user is not None:
             raise ValidationError('A user with this email already exists.')