← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] ~pappacena/launchpad:snap-create-on-project into launchpad:master

 

Pushed the requested changes.

Diff comments:

> diff --git a/lib/lp/snappy/browser/snap.py b/lib/lp/snappy/browser/snap.py
> index d4ba8bd..3a6d0c8 100644
> --- a/lib/lp/snappy/browser/snap.py
> +++ b/lib/lp/snappy/browser/snap.py
> @@ -138,6 +140,32 @@ class SnapNavigation(WebhookTargetNavigationMixin, Navigation):
>              return self.context.getSubscription(person)
>  
>  
> +class SnapFormMixin:
> +    def validateVCSWidgets(self, cls, data):
> +        """Validates if VCS sub-widgets."""
> +        if self.widgets.get('vcs') is not None:
> +            # Set widgets as required or optional depending on the vcs
> +            # field.
> +            super(cls, self).validate_widgets(data, ['vcs'])

Ok! Reordering it.

> +            vcs = data.get('vcs')
> +            if vcs == VCSType.BZR:
> +                self.widgets['branch'].context.required = True
> +                self.widgets['git_ref'].context.required = False
> +            elif vcs == VCSType.GIT:
> +                self.widgets['branch'].context.required = False
> +                self.widgets['git_ref'].context.required = True
> +            else:
> +                raise AssertionError("Unknown branch type %s" % vcs)
> +
> +    def setUpVCSWidgets(self):
> +        widget = self.widgets.get('vcs')
> +        if widget is not None:
> +            current_value = widget._getFormValue()
> +            self.vcs_bzr_radio, self.vcs_git_radio = [
> +                render_radio_widget_part(widget, value, current_value)
> +                for value in (VCSType.BZR, VCSType.GIT)]
> +
> +
>  class SnapInformationTypeMixin:
>      def getPossibleInformationTypes(self, snap, user):
>          """Get the information types to display on the edit form.


-- 
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/399184
Your team Launchpad code reviewers is subscribed to branch ~pappacena/launchpad:snap-pillar-edit.


References