def activation(self): if self.context.active: text = 'deactivate' return Link('+deactivate', text, icon='edit') else: text = 'activate' return Link('+activate', text, icon='edit')
def nominate(self): """Return the 'Target/Nominate for series' Link.""" launchbag = getUtility(ILaunchBag) target = launchbag.product or launchbag.distribution if check_permission("launchpad.Driver", target): text = "Target to series" return Link('+nominate', text, icon='milestone') elif (check_permission("launchpad.BugSupervisor", target) or self.user is None): text = 'Nominate for series' return Link('+nominate', text, icon='milestone') else: return Link('+nominate', '', enabled=False, icon='milestone')
def rescore(self): """Only enabled for pending build records.""" text = 'Rescore build' return Link('+rescore', text, icon='edit', enabled=self.context.can_be_rescored)
def addsubscriber(self): """Return the 'Subscribe someone else' Link.""" text = 'Subscribe someone else' return Link( '+addsubscriber', text, icon='add', summary=( 'Launchpad will email that person whenever this bugs ' 'changes'))
def pending_review_mirrors(self): text = 'Pending-review mirrors' enabled = self._userCanSeeNonPublicMirrorListings() return Link('+pendingreviewmirrors', text, enabled=enabled, icon='info')
def answer_contact_for(self): summary = "Projects for which %s is an answer contact" % ( self.context.displayname) return Link('+answer-contact-for', 'Answer contact for', summary, icon='edit')
def view_recipes(self): text = 'View source package recipes' enabled = False if self.context.recipes.count(): enabled = True return Link( '+recipes', text, icon='info', enabled=enabled, site='code')
def branches(self): """Return a link to view the branches related to this series.""" # Override to go to the branches for the product. text = 'Code' summary = 'View related branches of code' link = canonical_url(self.context.product, rootsite='code') return Link(link, text, summary=summary)
def configure_bugtracker(self): text = 'Configure bug tracker' summary = 'Specify where bugs are tracked for this project' return Link( canonical_url( self.context.product, view_name='+configure-bugtracker'), text, summary, icon='edit')
def cancel(self): """Only enabled for pending/active virtual builds.""" text = 'Cancel build' return Link('+cancel', text, icon='edit', enabled=self.context.can_be_cancelled)
def browse_commits(self): """Return a link to the branch's commit log.""" text = "All commits" url = "%s/log/?h=%s" % ( self.context.repository.getCodebrowseUrl(), quote_plus(self.context.name.encode("UTF-8"))) return Link(url, text)
def retry(self): """Only enabled for build records that are active.""" text = 'Retry this build' return Link('+retry', text, icon='retry', enabled=self.context.can_be_retried)
def translations_to_review(self): text = 'Translations to review' enabled = person_is_reviewer(self.person) return Link('+translations-to-review', text, enabled=enabled, icon='info', site='translations')
def licensing(self): text = 'Translations licensing' enabled = (self.person == self.user) return Link('+licensing', text, enabled=enabled, icon='info', site='translations')
def list_all(self): """Return a Link to list all FAQs.""" # We adapt to IFAQCollection so that the link can be used # on objects which don't provide `IFAQCollection` directly, but for # which an adapter exists that gives the proper context. collection = IFAQCollection(self.context) url = canonical_url(collection, rootsite='answers') + '/+faqs' return Link(url, 'List all FAQs', icon='info')
def linktocve(self): """Return the 'Link to CVE' Link.""" text = structured( 'Link to ' '<abbr title="Common Vulnerabilities and Exposures Index">' 'CVE' '</abbr>') return Link('+linkcve', text, icon='add')
def view_snaps(self): text = 'View snap packages' context = self.context if isinstance(context, DecoratedBranch): context = context.branch enabled = not getUtility(ISnapSet).findByContext( context, visible_by_user=self.user).is_empty() return Link('+snaps', text, icon='info', enabled=enabled)
def create_snap(self): # Only enabled if the snap_private flag is enabled for # private contexts. enabled = ( not self.context.private or bool(getFeatureFlag(SNAP_PRIVATE_FEATURE_FLAG))) text = 'Create snap package' return Link('+new-snap', text, enabled=enabled, icon='add')
def subscription(self): if self.context.hasSubscription(self.user): url = '+edit-subscription' text = 'Edit your subscription' icon = 'edit' else: url = '+subscribe' text = 'Subscribe yourself' icon = 'add' return Link(url, text, icon=icon)
def sign(self): text = 'Sign it' if (self.context.current and self.user and not self.user.is_ubuntu_coc_signer): # Then... enabled = True else: enabled = False return Link('+sign', text, enabled=enabled, icon='edit')
def set_branch(self): """Return a link to set the bazaar branch for this series.""" if self.context.branch is None: text = 'Link to branch' icon = 'add' summary = 'Set the branch for this series' else: text = "Change branch" icon = 'edit' summary = 'Change the branch for this series' return Link('+setbranch', text, summary, icon=icon)
def create_faq(self): """Return a Link to create a new FAQ.""" collection = IFAQCollection(self.context) if IProjectGroup.providedBy(self.context): url = '' enabled = False else: url = canonical_url(collection, view_name='+createfaq', rootsite='answers') enabled = True return Link(url, 'Create a new FAQ', icon='add', enabled=enabled)
def link_blueprint(self): if list(self.context.getSpecificationLinks(self.user)): text = 'Link to another blueprint' else: text = 'Link to a blueprint' # XXX: JonathanLange 2009-05-13 spec=package-branches: Actually, # distroseries can also have blueprints, so it makes sense to # associate package-branches with them. # # Since the blueprints are only related to products, there is no # point showing this link if the branch is junk. enabled = self.context.product is not None return Link('+linkblueprint', text, icon='add', enabled=enabled)
def translationdownload(self): text = 'Download' preferred_series = self.context.primary_translatable enabled = (service_uses_launchpad(self.context.translations_usage) and preferred_series is not None) link = '' if enabled: link = canonical_url(preferred_series, rootsite='translations', view_name='+export') text = 'Download "%s"' % preferred_series.name return Link(link, text, icon='download', enabled=enabled)
def mute_subscription(self): """Return the 'Mute subscription' Link.""" user = getUtility(ILaunchBag).user if self.context.bug.isMuted(user): text = "Unmute bug mail" icon = 'unmute' else: text = "Mute bug mail" icon = 'mute' return Link( '+mute', text, icon=icon, summary=( "Mute this bug so that you will not receive emails " "about it."))
def request_daily_build(self): """Provide a link for requesting a daily build of a recipe.""" recipe = self.context ppa = recipe.daily_build_archive if (ppa is None or not ppa.enabled or not recipe.build_daily or not recipe.is_stale or not recipe.distroseries): show_request_build = False else: has_upload = ppa.checkArchivePermission(recipe.owner) show_request_build = has_upload show_request_build = (show_request_build and check_permission('launchpad.Edit', recipe)) return Link('+request-daily-build', 'Build now', enabled=show_request_build)
def subscription(self): """Return the 'Subscribe/Unsubscribe' Link.""" user = getUtility(ILaunchBag).user if user is None: text = 'Subscribe/Unsubscribe' icon = 'edit' elif user is not None and ( self.context.bug.isSubscribed(user) or self.context.bug.isSubscribedToDupes(user)): if self.context.bug.isMuted(user): text = 'Subscribe' icon = 'add' else: text = 'Edit subscription' icon = 'edit' else: text = 'Subscribe' icon = 'add' return Link('+subscribe', text, icon=icon, summary=( 'When you are subscribed, Launchpad will email you each time ' 'this bug changes'))
def builds(self): text = 'Show builds' return Link('+builds', text, icon='info')
def set_upstream(self): return Link("+edit-packaging", "Set upstream link", icon="add", enabled=self.userCanDeletePackaging())
def remove_packaging(self): return Link('+remove-packaging', 'Remove upstream link', icon='remove', enabled=self.userCanDeletePackaging())