示例#1
0
 def render(value):
     # The value is a webservice link to the object, we want field value.
     obj = getattr(context, field.__name__, None)
     try:
         return format_link(obj, empty_value='')
     except NotImplementedError:
         return value
示例#2
0
 def test_public_build_private_team_with_permission(self):
     # Members of a private team can see their builds.
     build, p3a, team_owner = self._make_public_build_for_private_team()
     login_person(team_owner)
     self.assertIn(
         "[~%s/%s/%s]" % (p3a.owner.name, p3a.distribution.name, p3a.name),
         format_link(build))
 def render(value):
     # The value is a webservice link to the object, we want field value.
     obj = getattr(context, field.__name__, None)
     try:
         return format_link(obj, empty_value='')
     except NotImplementedError:
         return value
 def archive_picker(self):
     field = ISourcePackageEditSchema['daily_build_archive']
     return InlineEditPickerWidget(
         self.context, field,
         format_link(self.context.daily_build_archive),
         header='Change daily build archive',
         step_title='Select a PPA')
示例#5
0
 def maintainer_widget(self):
     return InlinePersonEditPickerWidget(
         self.context, IProjectGroup['owner'],
         format_link(self.context.owner, empty_value="Not yet selected"),
         header='Change maintainer', edit_view='+reassign',
         step_title='Select a new maintainer',
         null_display_value="Not yet selected", show_create_team=True)
示例#6
0
 def person_picker(self):
     field = copy_field(
         ISnap['owner'],
         vocabularyName='AllUserTeamsParticipationPlusSelfSimpleDisplay')
     return InlinePersonEditPickerWidget(
         self.context, field, format_link(self.context.owner),
         header='Change owner', step_title='Select a new owner')
示例#7
0
 def archive_picker(self):
     field = ISourcePackageEditSchema['daily_build_archive']
     return InlineEditPickerWidget(self.context,
                                   field,
                                   format_link(
                                       self.context.daily_build_archive),
                                   header='Change daily build archive',
                                   step_title='Select a PPA')
示例#8
0
 def test_public_build_private_team_no_permission(self):
     # A `PackageBuild` for a public `SourcePackageRelease` in an archive
     # for a private team is rendered gracefully when the user has no
     # permission.
     build, _, _ = self._make_public_build_for_private_team()
     # Make sure this is a valid test; the build itself must be public.
     self.assertTrue(check_permission('launchpad.View', build))
     self.assertEqual('private job', format_link(build))
示例#9
0
 def initialize(self):
     super(SourcePackageRecipeView, self).initialize()
     recipe = self.context
     if recipe.build_daily and recipe.daily_build_archive is None:
         self.request.response.addWarningNotification(
             structured(
                 "Daily builds for this recipe will <strong>not</strong> "
                 "occur.<br/><br/>There is no PPA."))
     elif self.dailyBuildWithoutUploadPermission():
         self.request.response.addWarningNotification(
             structured(
                 "Daily builds for this recipe will <strong>not</strong> "
                 "occur.<br/><br/>The owner of the recipe (%s) does not "
                 "have permission to upload packages into the daily "
                 "build PPA (%s)" %
                 (format_link(recipe.owner),
                  format_link(recipe.daily_build_archive))))
 def initialize(self):
     super(SourcePackageRecipeView, self).initialize()
     recipe = self.context
     if recipe.build_daily and recipe.daily_build_archive is None:
         self.request.response.addWarningNotification(
             structured(
                 "Daily builds for this recipe will <strong>not</strong> "
                 "occur.<br/><br/>There is no PPA."))
     elif self.dailyBuildWithoutUploadPermission():
         self.request.response.addWarningNotification(
             structured(
                 "Daily builds for this recipe will <strong>not</strong> "
                 "occur.<br/><br/>The owner of the recipe (%s) does not "
                 "have permission to upload packages into the daily "
                 "build PPA (%s)" % (
                     format_link(recipe.owner),
                     format_link(recipe.daily_build_archive))))
示例#11
0
 def driver_widget(self):
     return InlinePersonEditPickerWidget(
         self.context, IProjectGroup['driver'],
         format_link(self.context.driver, empty_value="Not yet selected"),
         header='Change driver', edit_view='+driver',
         step_title='Select a new driver',
         null_display_value="Not yet selected",
         help_link="/+help-registry/driver.html", show_create_team=True)
 def person_picker(self):
     field = copy_field(
         ISourcePackageRecipe['owner'],
         vocabularyName='UserTeamsParticipationPlusSelfSimpleDisplay')
     return InlinePersonEditPickerWidget(
         self.context, field,
         format_link(self.context.owner),
         header='Change owner',
         step_title='Select a new owner')
示例#13
0
 def maintainer_widget(self):
     return InlinePersonEditPickerWidget(
         self.context,
         IDistribution['owner'],
         format_link(self.context.owner),
         header='Change maintainer',
         edit_view='+reassign',
         step_title='Select a new maintainer',
         show_create_team=True)
示例#14
0
 def render(value):
     distroseries = sorted(context.distroseries,
                           key=lambda ds: ds.displayname)
     if not distroseries:
         return 'None'
     html = "<ul>"
     html += ''.join(
         ["<li>%s</li>" % format_link(series) for series in distroseries])
     html += "</ul>"
     return html
示例#15
0
 def maintainer_widget(self):
     return InlinePersonEditPickerWidget(
         self.context,
         IProjectGroup['owner'],
         format_link(self.context.owner, empty_value="Not yet selected"),
         header='Change maintainer',
         edit_view='+reassign',
         step_title='Select a new maintainer',
         null_display_value="Not yet selected",
         show_create_team=True)
 def render(value):
     distroseries = sorted(
         context.distroseries, key=lambda ds: ds.displayname)
     if not distroseries:
         return 'None'
     html = "<ul>"
     html += ''.join(
         ["<li>%s</li>" % format_link(series) for series in distroseries])
     html += "</ul>"
     return html
示例#17
0
 def maintainer_widget(self):
     return InlinePersonEditPickerWidget(
         self.context,
         IDistribution["owner"],
         format_link(self.context.owner),
         header="Change maintainer",
         edit_view="+reassign",
         step_title="Select a new maintainer",
         show_create_team=True,
     )
示例#18
0
 def members_widget(self):
     if canWrite(self.context, 'members'):
         empty_value = ' Specify the members team'
     else:
         empty_value = 'None'
     return InlinePersonEditPickerWidget(
         self.context, IDistribution['members'],
         format_link(self.context.members, empty_value=empty_value),
         header='Change the members team', edit_view='+selectmemberteam',
         null_display_value=empty_value,
         step_title='Select a new members team')
示例#19
0
 def driver_widget(self):
     if canWrite(self.context, 'driver'):
         empty_value = 'Specify a driver'
     else:
         empty_value = 'None'
     return InlinePersonEditPickerWidget(
         self.context, IDistribution['driver'],
         format_link(self.context.driver, empty_value=empty_value),
         header='Change driver', edit_view='+driver',
         null_display_value=empty_value,
         step_title='Select a new driver', show_create_team=True)
示例#20
0
 def driver_widget(self):
     return InlinePersonEditPickerWidget(
         self.context,
         IProjectGroup['driver'],
         format_link(self.context.driver, empty_value="Not yet selected"),
         header='Change driver',
         edit_view='+driver',
         step_title='Select a new driver',
         null_display_value="Not yet selected",
         help_link="/+help-registry/driver.html",
         show_create_team=True)
示例#21
0
 def mirror_admin_widget(self):
     if canWrite(self.context, 'mirror_admin'):
         empty_value = ' Specify a mirror administrator'
     else:
         empty_value = 'None'
     return InlinePersonEditPickerWidget(
         self.context, IDistribution['mirror_admin'],
         format_link(self.context.mirror_admin, empty_value=empty_value),
         header='Change the mirror administrator',
         edit_view='+selectmirroradmins', null_display_value=empty_value,
         step_title='Select a new mirror administrator')
 def test_person(self):
     # Test the XHTML representation of a person.
     eric = self.factory.makePerson()
     # We need something that has an IPersonChoice, a project will do.
     product = self.factory.makeProduct(owner=eric)
     field = IProduct['owner']
     request = get_current_web_service_request()
     renderer = getMultiAdapter(
         (product, field, request), IFieldHTMLRenderer)
     # The representation of a person is the same as a tales
     # PersonFormatter.
     self.assertEqual(format_link(eric), renderer(eric))
 def test_completer_set(self):
     user = self.factory.makePerson()
     blueprint = self.factory.makeBlueprint(owner=user)
     when = datetime(2011, 1, 1, tzinfo=pytz.UTC)
     with person_logged_in(user):
         blueprint.setImplementationStatus(
             SpecificationImplementationStatus.IMPLEMENTED, user)
     removeSecurityProxy(blueprint).date_completed = when
     repr_method = specification.completer_xhtml_representation(
         blueprint, ISpecification['completer'], None)
     expected = format_link(user) + ' on 2011-01-01'
     self.assertThat(repr_method(), Equals(expected))
 def test_completer_set(self):
     user = self.factory.makePerson()
     blueprint = self.factory.makeBlueprint(owner=user)
     when = datetime(2011, 1, 1, tzinfo=pytz.UTC)
     with person_logged_in(user):
         blueprint.setImplementationStatus(
             SpecificationImplementationStatus.IMPLEMENTED, user)
     removeSecurityProxy(blueprint).date_completed = when
     repr_method = specification.completer_xhtml_representation(
         blueprint, ISpecification['completer'], None)
     expected = format_link(user) + ' on 2011-01-01'
     self.assertThat(repr_method(), Equals(expected))
示例#25
0
 def members_widget(self):
     if canWrite(self.context, "members"):
         empty_value = " Specify the members team"
     else:
         empty_value = "None"
     return InlinePersonEditPickerWidget(
         self.context,
         IDistribution["members"],
         format_link(self.context.members, empty_value=empty_value),
         header="Change the members team",
         edit_view="+selectmemberteam",
         null_display_value=empty_value,
         step_title="Select a new members team",
     )
示例#26
0
 def mirror_admin_widget(self):
     if canWrite(self.context, "mirror_admin"):
         empty_value = " Specify a mirror administrator"
     else:
         empty_value = "None"
     return InlinePersonEditPickerWidget(
         self.context,
         IDistribution["mirror_admin"],
         format_link(self.context.mirror_admin, empty_value=empty_value),
         header="Change the mirror administrator",
         edit_view="+selectmirroradmins",
         null_display_value=empty_value,
         step_title="Select a new mirror administrator",
     )
示例#27
0
 def driver_widget(self):
     if canWrite(self.context, "driver"):
         empty_value = "Specify a driver"
     else:
         empty_value = "None"
     return InlinePersonEditPickerWidget(
         self.context,
         IDistribution["driver"],
         format_link(self.context.driver, empty_value=empty_value),
         header="Change driver",
         edit_view="+driver",
         null_display_value=empty_value,
         step_title="Select a new driver",
         show_create_team=True,
     )
示例#28
0
 def test_public_build_private_team_with_permission(self):
     # Members of a private team can see their builds.
     build, p3a, team_owner = self._make_public_build_for_private_team()
     login_person(team_owner)
     self.assertIn(
         "[%s/%s]" % (p3a.owner.name, p3a.name), format_link(build))
示例#29
0
 def test_format_link_none(self):
     # Test that format_link() handles None correctly.
     self.assertEqual(format_link(None), 'None')
     self.assertEqual(format_link(None, empty_value=''), '')
 def html_link(self):
     return format_link(self.spec)
 def target_link(self):
     return format_link(self.target)
 def assignee_link(self):
     if self.assignee is None:
         return 'Nobody'
     return format_link(self.assignee)