~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/distroseries.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    'DistroSeriesView',
20
20
    ]
21
21
 
 
22
from lazr.restful.interface import copy_field
22
23
from zope.component import getUtility
23
24
from zope.event import notify
24
25
from zope.formlib import form
39
40
    _,
40
41
    helpers,
41
42
    )
42
 
from canonical.launchpad.interfaces.launchpad import ILaunchBag
43
43
from canonical.launchpad.webapp import (
44
44
    action,
45
45
    custom_widget,
504
504
        self.next_url = canonical_url(self.context)
505
505
 
506
506
 
 
507
class IDistroSeriesAddForm(Interface):
 
508
 
 
509
    name = copy_field(
 
510
        IDistroSeries["name"], description=_(
 
511
            "The name of this series as used for URLs."))
 
512
 
 
513
    version = copy_field(
 
514
        IDistroSeries["version"], description=_(
 
515
            "The version of the new series."))
 
516
 
 
517
    displayname = copy_field(
 
518
        IDistroSeries["displayname"], description=_(
 
519
            "The name of the new series as it would "
 
520
            "appear in a paragraph."))
 
521
 
 
522
    summary = copy_field(IDistroSeries["summary"])
 
523
 
 
524
 
507
525
class DistroSeriesAddView(LaunchpadFormView):
508
526
    """A view to create an `IDistroSeries`."""
509
 
    schema = IDistroSeries
 
527
    schema = IDistroSeriesAddForm
510
528
    field_names = [
511
 
        'name', 'displayname', 'title', 'summary', 'description', 'version',
512
 
        'parent_series']
513
 
 
514
 
    label = 'Register a series'
 
529
        'name',
 
530
        'version',
 
531
        'displayname',
 
532
        'summary',
 
533
        ]
 
534
 
 
535
    help_links = {
 
536
        "name": u"/+help/distribution-add-series.html#codename",
 
537
        }
 
538
 
 
539
    label = 'Add a series'
515
540
    page_title = label
516
541
 
517
 
    @action(_('Create Series'), name='create')
 
542
    @action(_('Add Series'), name='create')
518
543
    def createAndAdd(self, action, data):
519
544
        """Create and add a new Distribution Series"""
520
 
        registrant = getUtility(ILaunchBag).user
521
 
 
522
 
        assert registrant is not None
523
545
        distroseries = self.context.newSeries(
524
546
            name=data['name'],
525
547
            displayname=data['displayname'],
526
 
            title=data['title'],
 
548
            title=data['displayname'],
527
549
            summary=data['summary'],
528
 
            description=data['description'],
 
550
            description=u"",
529
551
            version=data['version'],
530
 
            parent_series=data['parent_series'],
531
 
            registrant=registrant)
 
552
            parent_series=None,
 
553
            registrant=self.user)
532
554
        notify(ObjectCreatedEvent(distroseries))
533
555
        self.next_url = canonical_url(distroseries)
534
556
        return distroseries