73
73
raise KeyError, name
76
def newBugTracker(form, owner):
77
"""Process a form to create a new BugSystem Bug Tracking instance
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").
84
if not form.has_key('Register'): return
85
if not form['Register'] == 'Register Bug Tracker': return
87
# Extract the BugSystem details, which are in self.form
91
shortdesc = form['shortdesc']
92
baseurl = form['baseurl']
93
contactdetails = form['contactdetails']
95
# XXX Mark Shuttleworth 05/10/04 Hardcoded Bugzilla for the moment
99
# Create the new BugSystem
101
bugsystem = BugSystem(name=name,
102
bugsystemtype=bugsystemtype,
106
contactdetails=contactdetails,
109
# return the bugsystem
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
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
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").
562
if not self.form.has_key('Register'): return
563
if not self.form['Register'] == 'Register Bug Tracker': return
565
# Extract the BugSystem details, which are in self.form
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']
573
# XXX Mark Shuttleworth 05/10/04 Hardcoded Bugzilla for the moment
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
577
595
# The person who is logged in needs to end up owning this bug
578
596
# tracking instance.
580
598
owner = IPerson(self.request.principal).id
582
# Create the new BugSystem
584
bugsystem = BugSystem(name=name,
585
bugsystemtype=bugsystemtype,
589
contactdetails=contactdetails,
600
# Try to process the form
602
bugsystem = newBugTracker(self.form, owner)
603
if not bugsystem: return
592
604
# Now redirect to view it again
594
605
self.request.response.redirect(self.request.URL[-1])
597
609
class BugSystemView(object):
598
610
def __init__(self, context, request):
599
611
self.context = context