def save_tag(self, id=None, tag=None, *args, **kw): try: distro = Distro.by_id(id) except InvalidRequestError: flash(_(u"Invalid distro id %s" % id)) redirect(".") if tag['text']: distro.tags.append(tag['text']) distro.activity.append(DistroActivity( user=identity.current.user, service=u'WEBUI', action=u'Added', field_name=u'Tag', old_value=None, new_value=tag['text'])) flash(_(u"Added Tag %s" % tag['text'])) redirect("./view?id=%s" % id)
def tag_remove(self, id=None, tag=None, *args, **kw): try: distro = Distro.by_id(id) except InvalidRequestError: flash(_(u"Invalid distro id %s" % id)) redirect(".") if tag: for dtag in distro.tags: if dtag == tag: distro.tags.remove(dtag) distro.activity.append(DistroActivity( user=identity.current.user, service=u'WEBUI', action=u'Removed', field_name=u'Tag', old_value=tag, new_value=None)) flash(_(u"Removed Tag %s" % tag)) redirect("./view?id=%s" % id)
def view(self, id=None, *args, **kw): try: distro = Distro.by_id(id) except InvalidRequestError: flash(_(u"Invalid distro id %s" % id)) redirect(".") is_admin = identity.current.user and identity.current.user.is_admin( ) or False task_form = TaskSearchForm(hidden=dict(distro=True, osmajor_id=True)) return dict(title='Distro', value=distro, value_task=dict(distro_id=distro.id), form=self.tag_form, form_task=task_form, action='./save_tag', action_task='/tasks/do_search', options=dict(tags=distro.tags, readonly=not is_admin))
def view(self, id=None, *args, **kw): try: distro = Distro.by_id(id) except InvalidRequestError: flash(_(u"Invalid distro id %s" % id)) redirect(".") is_admin = identity.current.user and identity.current.user.is_admin() or False task_form = TaskSearchForm(hidden=dict(distro=True, osmajor_id=True)) return dict(title = 'Distro', value = distro, value_task = dict(distro_id = distro.id), form = self.tag_form, form_task = task_form, action = './save_tag', action_task = '/tasks/do_search', options = dict(tags = distro.tags, readonly = not is_admin))