def distro(self, **kw): activities = DistroActivity.all() activity_search = search_utility.DistroActivity.search search_bar = SearchBar(activity_search.create_complete_search_table(), name='activitysearch',) return self._activities_grid(activities, search_bar, 'distro', search_utility.DistroActivity, title='Distro Activity', **kw)
def tag(self, name, tag): """ Applies the given tag to all matching distros. :param name: distro name to filter by (may include SQL wildcards) :type name: string or nil :param tag: tag to be applied :type tag: string :returns: list of distro names which have been modified .. versionchanged:: 0.9 Removed *arch* parameter. Tags apply to distros and not distro trees. """ added = [] distros = Distro.query.filter(Distro.name.like('%s' % name)) for distro in distros: if tag not in distro.tags: added.append('%s' % distro.name) distro.activity.append( DistroActivity(user=identity.current.user, service=u'XMLRPC', action=u'Added', field_name=u'Tag', old_value=None, new_value=tag)) distro.tags.append(tag) return added
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 untag(self, name, tag): """ Like :meth:`distros.tag` but the opposite. """ removed = [] distros = Distro.query.filter(Distro.name.like('%s' % name)) for distro in distros: if tag in distro.tags: removed.append('%s' % distro.name) distro.activity.append(DistroActivity( user=identity.current.user, service=u'XMLRPC', action=u'Removed', field_name=u'Tag', old_value=tag, new_value=None)) distro.tags.remove(tag) return removed
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 setUp(self): self.distro = data_setup.create_distro() self.distro_tree1 = data_setup.create_distro_tree(distro=self.distro, arch='x86_64') self.distro_tree2 = data_setup.create_distro_tree(distro=self.distro, arch='i386') self.distro_tree1.activity.append( DistroTreeActivity(user=User.by_user_name(data_setup.ADMIN_USER), service=u'testdata', field_name=u'Nonesente', old_value=u'sdfas', new_value=u'sdfa', action='Added')) self.distro_tree2.activity.append( DistroTreeActivity(user=User.by_user_name(data_setup.ADMIN_USER), service=u'testdata', field_name=u'Noneseonce', old_value=u'bsdf', new_value=u'sdfas', action='Added')) self.distro.activity.append( DistroActivity(user=User.by_user_name(data_setup.ADMIN_USER), service=u'testdata', action=u'Nothing', field_name=u'Nonsense', old_value=u'asdf', new_value=u'omgwtfbbq')) self.system = data_setup.create_system() self.system.activity.append( SystemActivity(user=User.by_user_name(data_setup.ADMIN_USER), service=u'testdata', action=u'Nothing', field_name=u'Nonsense', old_value=u'asdf', new_value=u'omgwtfbbq')) self.group2 = data_setup.create_group() self.group = data_setup.create_group() self.group.activity.append( GroupActivity(user=User.by_user_name(data_setup.ADMIN_USER), service=u'testdata', action=u'Nothing', field_name=u'Nonsense', old_value=u'asdf', new_value=u'omgwtfbbq')) self.browser = self.get_browser()
def edit_version(self, name, version): """ Updates the version for all distros with the given name. :param name: name of distros to be updated, for example 'RHEL5.6-Server-20101110.0' :type name: string :param version: new version to be applied, for example 'RedHatEnterpriseLinuxServer5.6' or 'Fedora14' :type version: string """ distros = Distro.query.filter(Distro.name.like(unicode(name))) edited = [] os_major = version.split('.')[0] # Try and split OSMinor try: os_minor = version.split('.')[1] except IndexError: os_minor = '0' # Try and find OSMajor osmajor = OSMajor.lazy_create(osmajor=os_major) # Try and find OSVersion osversion = OSVersion.lazy_create(osmajor=osmajor, osminor=os_minor) # Check each Distro for distro in distros: if osversion != distro.osversion: edited.append('%s' % distro.name) distro.activity.append( DistroActivity(user=identity.current.user, service=u'XMLRPC', field_name=u'osversion', action=u'Changed', old_value=unicode(distro.osversion), new_value=unicode(osversion))) distro.osversion = osversion return edited