Example #1
0
 def update(self, id, **kw):
     # XXX Thus function is awkward and needs to be cleaned up.
     try:
         job = Job.by_id(id)
     except InvalidRequestError:
         raise cherrypy.HTTPError(status=400, message='Invalid job id %s' % id)
     if not job.can_change_product(identity.current.user) or not \
         job.can_change_retention_tag(identity.current.user):
         raise cherrypy.HTTPError(status=403,
                 message="You don't have permission to update job id %s" % id)
     returns = {'success' : True, 'vars':{}}
     if 'retentiontag' in kw and 'product' in kw:
         retention_tag = RetentionTag.by_id(kw['retentiontag'])
         if int(kw['product']) == ProductWidget.product_deselected:
             product = None
         else:
             product = Product.by_id(kw['product'])
         returns.update(Utility.update_retention_tag_and_product(job,
                 retention_tag, product))
     elif 'retentiontag' in kw:
         retention_tag = RetentionTag.by_id(kw['retentiontag'])
         returns.update(Utility.update_retention_tag(job, retention_tag))
     elif 'product' in kw:
         if int(kw['product']) == ProductWidget.product_deselected:
             product = None
         else:
             product = Product.by_id(kw['product'])
         returns.update(Utility.update_product(job, product))
     if 'whiteboard' in kw:
         job.whiteboard = kw['whiteboard']
     return returns
Example #2
0
 def update(self, id, **kw):
     # XXX Thus function is awkward and needs to be cleaned up.
     try:
         job = Job.by_id(id)
     except InvalidRequestError:
         raise cherrypy.HTTPError(status=400,
                                  message='Invalid job id %s' % id)
     if not job.can_change_product(identity.current.user) or not \
         job.can_change_retention_tag(identity.current.user):
         raise cherrypy.HTTPError(
             status=403,
             message="You don't have permission to update job id %s" % id)
     returns = {'success': True, 'vars': {}}
     if 'retentiontag' in kw and 'product' in kw:
         retention_tag = RetentionTag.by_id(kw['retentiontag'])
         if int(kw['product']) == ProductWidget.product_deselected:
             product = None
         else:
             product = Product.by_id(kw['product'])
         old_tag = job.retention_tag if job.retention_tag else None
         returns.update(
             Utility.update_retention_tag_and_product(
                 job, retention_tag, product))
         job.record_activity(user=identity.current.user,
                             service=u'WEBUI',
                             field=u'Retention Tag',
                             action='Changed',
                             old=old_tag.tag,
                             new=retention_tag.tag)
     elif 'retentiontag' in kw:
         retention_tag = RetentionTag.by_id(kw['retentiontag'])
         old_tag = job.retention_tag if job.retention_tag else None
         returns.update(Utility.update_retention_tag(job, retention_tag))
         job.record_activity(user=identity.current.user,
                             service=u'WEBUI',
                             field=u'Retention Tag',
                             action='Changed',
                             old=old_tag.tag,
                             new=retention_tag.tag)
     elif 'product' in kw:
         if int(kw['product']) == ProductWidget.product_deselected:
             product = None
         else:
             product = Product.by_id(kw['product'])
         returns.update(Utility.update_product(job, product))
     if 'whiteboard' in kw:
         job.whiteboard = kw['whiteboard']
     return returns
Example #3
0
    def update_task_product(cls, job, retentiontag_id=None, product_id=None):
        if product_id is ProductWidget.product_deselected:
            product = product_id
        elif product_id is not None:
            try:
                product = Product.by_id(product_id)
            except NoResultFound:
                raise ValueError('%s is not a valid product' % product_id)
        else:
            product=None

        if retentiontag_id:
            try:
                retentiontag = RetentionTag.by_id(retentiontag_id)
            except NoResultFound:
                raise ValueError('%s is not a valid retention tag' % retentiontag_id)
        else:
            retentiontag = None
        if retentiontag is None and product is None:
            return {'success': False}
        if retentiontag is not None and product is None: #trying to update retentiontag only
            return cls.check_retentiontag_job(job, retentiontag)
        elif retentiontag is None and product is not None: #only product
            return cls.check_product_job(job, product)
        else: #updating both
           return cls._update_task_product(job, product, retentiontag)
 def edit_default(cls, **kw):
     is_default =  bool(int(kw.get('default')))
     id = kw.get('id')
     needs_product = bool(kw.get('needs_product', None))
     tag = RetentionTag.by_id(id)
     tag.default = is_default 
     tag.needs_product = needs_product 
Example #5
0
 def delete(self, id):
     tag = Tag.by_id(id)
     if not tag.can_delete(): # Trying to be funny...
         flash(u'%s is not applicable for deletion' % tag.tag)
         redirect('/retentiontag/admin')
     session.delete(tag)
     flash(u'Successfully deleted %s' % tag.tag)
     redirect('/retentiontag/admin')
Example #6
0
 def save_edit(self, id=None, **kw):
     retention_tag = Tag.by_id(id)
     retention_tag.tag = kw['tag']
     retention_tag.default = kw['default']
     retention_tag.expire_in_days = kw['expire_in_days']
     retention_tag.needs_product = kw['needs_product']
     flash(_(u"OK"))
     redirect("./admin")
Example #7
0
 def edit(self, id, **kw):
     tag = Tag.by_id(id)
     return dict(form=self.tag_form,
                 title=_(u'Retention tag %s' % tag.tag),
                 action='./save_edit',
                 options={},
                 value=tag,
                 disabled_fields=['tag'])
Example #8
0
 def edit(self, id, **kw):
     tag = Tag.by_id(id) 
     return dict(
         form = self.tag_form,
         action = './save_edit',
         options = {},
         value = tag,
         disabled_fields = ['tag']
     )