示例#1
0
def tickets():
    if request.method == 'GET':
        project_id = request.args.get('project_id')
        kwargs = {
            'num': 20,
            'max_id': float(request.args.get('max_id', 'inf'))
        }
        index = 'connects'
        if project_id:
            kwargs['part'] = 'project'
            kwargs['project'] = project_id
        items = Ticket.all(index=index, **kwargs)
        items = Ticket.assemble_with_connects(items)
        return serialize({
            'continuation':
            decrease(Ticket.make_unique_index(peek(items), index))
            if len(items) >= kwargs['num'] and peek(items) else None,
            'items':
            items
        })
    else:
        form = TicketForm(csrf_enabled=False)
        if form.validate_on_submit():
            t = Ticket(project=form.project.data,
                       name=form.name.data,
                       description=form.description.data,
                       connects=0)
            t.save()
            return serialize(t)
        else:
            return make_response(serialize({'errors': form.errors}), 400)
示例#2
0
文件: views.py 项目: gnkr8/feedback
def projects():
    if request.method == 'GET':
        return render_template('admin.html', projects=Project.all())
    elif request.method == 'POST':
        form = ProjectForm()
        if form.validate_on_submit():
            p = Project(name=form.name.data, description=form.description.data)
            p.save()
            return serialize(p)
        else:
            return make_response(serialize({'errors': form.errors}), 400)
示例#3
0
def project(id):
  form = ProjectForm(csrf_enabled=False)
  if form.validate_on_submit():
    p = Project.get_by_id(id)
    if p is not None:
      p.name = form.name.data
      p.description = form.description.data
      p.save()
    return serialize(p)
  else:
    p = Project.get_by_id(id)
    return serialize(p)
示例#4
0
文件: views.py 项目: gnkr8/feedback
def projects():
  if request.method == 'GET':
    return render_template('admin.html', projects = Project.all())
  elif request.method == 'POST':
    form = ProjectForm()
    if form.validate_on_submit():
      p = Project(name = form.name.data
        , description = form.description.data)
      p.save()
      return serialize(p)
    else:
      return make_response(serialize({
        'errors': form.errors
      }), 400)
示例#5
0
def ticket(id):
    form = TicketForm(csrf_enabled=False)
    t = Ticket.get_by_id(id)
    if request.method == 'DELETE':
        t.delete()
        return serialize(t)
    if form.validate_on_submit():
        if t is not None:
            t.name = form.name.data
            t.description = form.description.data
            t.published = form.published.data
            t.save()
        return serialize(t)
    else:
        return serialize(t)
示例#6
0
def projects():
  if request.method == 'GET':
    max_id = float(request.args.get('max_id', 'inf'))
    items = Project.all(max_id = max_id, num = 1000000, order='asc')
    return serialize({
      'items': items
    })