Exemple #1
0
 def edit(self, id):
     c.order = h.checkorder(id)
     # Теперь - проверка прав доступа (админ либо ответственный подразделения, создавшего заявку)
     h.requirelogin()
     if not (
         h.have_role("admin")
         or h.have_role("operator")
         or (
             session.has_key("division")
             and (h.have_role("creator") and c.order.cust_id == session["division"])
             or (h.have_role("responsible") and c.order.perf_id == session["division"])
         )
     ):
         abort(403)
     work = meta.Session.query(model.Work).order_by(model.Work.id).all()
     c.work = []
     for i in work:
         c.work.append([i.id, i.title])
     category = (
         meta.Session.query(model.Category)
         .filter(model.Category.upcat_id == c.order.upper_category.id)
         .order_by(model.Category.id)
         .all()
     )
     c.category = []
     for i in category:
         c.category.append([i.id, i.title])
     upcategory = (
         meta.Session.query(model.UpperCategory).filter_by(deleted=False).order_by(model.UpperCategory.id).all()
     )
     c.upcategory = [[None, u" -- выберите надкатегорию -- "]]
     for i in upcategory:
         c.upcategory.append([i.id, i.title])
     return render("/orders/edit.html")
Exemple #2
0
 def save(self, id):
     h.requirelogin()
     div = h.checkdiv(id)
     if not (h.have_role('admin') or (session.get('division')==div.id and (session.get('chief') or session.get('responsible')))):
         abort(403)
     for key, value in self.form_result.items():
         if getattr(div, key) != value:
             setattr(div, key, value)
     meta.Session.commit()
     h.flashmsg (u"Информация о подразделении была сохранена")
     redirect_to(h.url_for(controller='division', action='view', id=div.id))
Exemple #3
0
 def edit(self, id=None):
     h.requirelogin()
     div = h.checkdiv(id)
     if not (h.have_role('admin') or (session.get('division')==div.id and (session.get('chief') or session.get('responsible')))):
         abort(403)
     users = meta.Session.query(model.Person).all()
     c.users = []
     for i in users:
         c.users.append([i.id, h.name(i)])
     #qmembers = meta.Session.query(model.Person).filter_by(division=div.id).all()
     members = []
     for i in div.people:
         members.append(i.id)
     values = {
         'title': div.title,
         'address': div.address,
         'description': div.description,
         'email': div.email,
         'phone': div.phone,
         'users': members,
     }
     return htmlfill.render(render("/divisions/edit.html"), values)