~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/malone/browser.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2004-10-06 00:28:55 UTC
  • mfrom: (unknown (missing))
  • Revision ID: Arch-1:rocketfuel@canonical.com%launchpad--devel--0--patch-522
renaming phase 2
Patches applied:

 * mark.shuttleworth@canonical.com/launchpad--devel--0--patch-164
   merge rocketfuel

 * mark.shuttleworth@canonical.com/launchpad--devel--0--patch-165
   renaming phase 2, and projectbugtracker work

 * mark.shuttleworth@canonical.com/launchpad--devel--0--patch-166
   merge rocketfuel

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
        raise KeyError, name
74
74
 
75
75
 
 
76
def newBugTracker(form, owner):
 
77
    """Process a form to create a new BugSystem Bug Tracking instance
 
78
    object."""
 
79
    #
 
80
    # Verify that the form was in fact submitted, and that it looks like
 
81
    # the right form (by checking the contents of the submit button
 
82
    # field, called "Update").
 
83
    #
 
84
    if not form.has_key('Register'): return
 
85
    if not form['Register'] == 'Register Bug Tracker': return
 
86
    #
 
87
    # Extract the BugSystem details, which are in self.form
 
88
    #
 
89
    name = form['name']
 
90
    title = form['title']
 
91
    shortdesc = form['shortdesc']
 
92
    baseurl = form['baseurl']
 
93
    contactdetails = form['contactdetails']
 
94
    #
 
95
    # XXX Mark Shuttleworth 05/10/04 Hardcoded Bugzilla for the moment
 
96
    #
 
97
    bugsystemtype = 1
 
98
    #
 
99
    # Create the new BugSystem
 
100
    #
 
101
    bugsystem = BugSystem(name=name,
 
102
                          bugsystemtype=bugsystemtype,
 
103
                          title=title,
 
104
                          shortdesc=shortdesc,
 
105
                          baseurl=baseurl,
 
106
                          contactdetails=contactdetails,
 
107
                          owner=owner)
 
108
    #
 
109
    # return the bugsystem
 
110
    #
 
111
    return bugsystem
 
112
 
 
113
 
76
114
class MaloneApplicationView(object):
77
115
    def __init__(self, context, request):
78
116
        self.context = context
547
585
        self.request = request
548
586
        self.form = request.form
549
587
        
550
 
    def new(self):
551
 
        """Process a form to create a new BugSystem Bug Tracking instance
552
 
        object. This method is triggered by a tal:dummy element in the page
 
588
    def newBugTracker(self):
 
589
        """This method is triggered by a tal:dummy element in the page
553
590
        template, so it is run even when the page is first displayed. It
554
 
        determines whether or not a form has been submitted, and if so it
555
 
        updates itself accordingly and redirects back to its display
556
 
        page."""
557
 
        #
558
 
        # Verify that the form was in fact submitted, and that it looks like
559
 
        # the right form (by checking the contents of the submit button
560
 
        # field, called "Update").
561
 
        #
562
 
        if not self.form.has_key('Register'): return
563
 
        if not self.form['Register'] == 'Register Bug Tracker': return
564
 
        #
565
 
        # Extract the BugSystem details, which are in self.form
566
 
        #
567
 
        name = self.form['name']
568
 
        title = self.form['title']
569
 
        shortdesc = self.form['shortdesc']
570
 
        baseurl = self.form['baseurl']
571
 
        contactdetails = self.form['contactdetails']
572
 
        #
573
 
        # XXX Mark Shuttleworth 05/10/04 Hardcoded Bugzilla for the moment
574
 
        #
575
 
        bugsystemtype = 1
 
591
        calls newBugTracker which will check if a form has been submitted,
 
592
        and if so it creates one accordingly and redirects back to its
 
593
        display page."""
576
594
        #
577
595
        # The person who is logged in needs to end up owning this bug
578
596
        # tracking instance.
579
597
        #
580
598
        owner = IPerson(self.request.principal).id
581
599
        #
582
 
        # Create the new BugSystem
583
 
        #
584
 
        bugsystem = BugSystem(name=name,
585
 
                              bugsystemtype=bugsystemtype,
586
 
                              title=title,
587
 
                              shortdesc=shortdesc,
588
 
                              baseurl=baseurl,
589
 
                              contactdetails=contactdetails,
590
 
                              owner=owner)
591
 
        #
 
600
        # Try to process the form
 
601
        #
 
602
        bugsystem = newBugTracker(self.form, owner)
 
603
        if not bugsystem: return
592
604
        # Now redirect to view it again
593
 
        #
594
605
        self.request.response.redirect(self.request.URL[-1])
595
606
 
596
607
 
 
608
 
597
609
class BugSystemView(object):
598
610
    def __init__(self, context, request):
599
611
        self.context = context