Exemple #1
0
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     if user:
         templates.header(wfile)
         templates.title(
             wfile,
             "Daily progress")
         progress = self.application.bugs.summary.get_progress()
         if len(progress.rows) > 0:
             templates.bullets(
                 wfile,
                 "The following table summarises activity"
                 " over the last %d days" % config.History.progress_max_age,
                 "Each row displays the net change in the number of"
                 " bugs in each status over each day.",
                 "The table is updated every hour on the hour, so todays row"
                 " potentially changes throughout the day.")
             templates.table_of_progress(wfile, progress)
         else:
             templates.paragraph(
                 wfile,
                 "No history available (yet).")
         templates.footer(wfile)
     else:
         values["next"] = self.path
         path = lib.join_url(Login.path, values)
         self.redirect(path)
Exemple #2
0
 def _report_on_changes(self, session_id, old_bug, changes, wfile):
     new_bug = self.application.get_bug(session_id, old_bug.bug_id)
     if changes:
         templates.title(wfile, "Bug update successful")
         bullet_items = []
         if changes.pop("comment", None):
             bullet_items.append("Added new comment.")
         for variable, new_value in changes.iteritems():
             old_value = getattr(old_bug, variable)
             variable = variable.capitalize().replace("_", " ")
             if old_value and new_value:
                 bullet_items.append('Changed "%s" from %s to %s.' % \
                                     (variable, old_value, new_value))
             else:
                 if old_value:
                     bullet_items.append('Unset "%s".' % variable)
                 else:
                     bullet_items.append('Set "%s" to %s.' % \
                                         (variable, new_value))
         templates.bullets(wfile, *bullet_items)
     else:
         templates.title(wfile, "No update needed")
     templates.hrule(wfile)
     templates.title(wfile, new_bug.title)
     self._show_status_and_comments_and_form(wfile, new_bug)
Exemple #3
0
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     if user:
         templates.header(wfile)
         templates.title(wfile, "Recent changes")
         sort_by = values.get("sort_by", "date")
         order = values.get("order", "descending")
         changes = self.application.bugs.changes.get_recent_changes(
             sort_by, order)
         if len(changes.rows) > 0:
             templates.bullets(
                 wfile,
                 "The following table displays the last"
                 " %d days of changes made to bugs." % config.History.changes_max_age,
                 "This includes the addition of new bugs.",
                 "The table is updated every hour on the hour.")
             templates.table_of_changes(wfile, self.path, changes)
         else:
             templates.paragraph(
                 wfile,
                 "There have been no changes made in the last"
                 " %d days." % config.History.changes_max_age)
         templates.footer(wfile)
     else:
         values["next"] = self.path
         path = lib.join_url(Login.path, values)
         self.redirect(path)
Exemple #4
0
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     if user:
         status = values.pop("status", None)
         sort_by = values.pop("sort_by", None)
         order = values.pop("order", None)
         show_method_name = "_show_%s" % status
         if hasattr(self, show_method_name):
             show_method = getattr(self, show_method_name)
             templates.header(wfile)
             show_method(session_id, wfile, sort_by, order)
             templates.footer(wfile)
         else:
             templates.header(wfile)
             templates.title(wfile, "List bugs")
             templates.bullets(
                 wfile,
                 'Each bug list is designed for a particular objective.',
                 'Use the <a href="/search">Search bugs</a> page '
                 'for hand-crafted listings.')
             status_counts = self.application.get_status_counts(session_id)
             templates.list_form(wfile, self.path, status_counts)
             templates.footer(wfile)
     else:
         values["next"] = self.path
         path = lib.join_url(Login.path, values)
         self.redirect(path)
Exemple #5
0
    def handle_post(self, session_id, values, post_data, wfile):
        user = self.application.get_user(session_id)
        
        username = post_data.get("username", None)
        name = post_data.get("name", None)
        email = post_data.get("email", None)
        password = post_data.get("password", None)
        password_again = post_data.get("password_again", None)

        templates.header(wfile)

        if username and name and email and password and password_again:
            if password == password_again:
                try:
                    self.application.create_new_user(username,
                                                     name,
                                                     email,
                                                     password)
                    templates.title(wfile, "New user account created ok")
                    templates.paragraph(
                        wfile,
                        "Continue to the login page to use this account.")
                    templates.possible_actions(wfile,
                                               ("login", "Login"))
                except application.ValueInUseException:
                    templates.title(wfile, "Failed to create user account!")
                    templates.paragraph(
                        wfile,
                        "The username you chose (<b>%s</b>) is already in "
                        "use by another user. " % username +
                        "Use the back-button of your browser and try "
                        "a different Username.")
            else:
                templates.title(wfile, "Failed to create user account!")
                templates.paragraph(
                    wfile,
                    "The passwords you provided do not match. "
                    "Use the back-button of your browser to try again.")
        else:
            templates.title(wfile, "Failed to create user account!")
            templates.paragraph(
                wfile,
                "You must provide the following information:")
            problems = [description
                        for (item, description) in ((username, "Username"),
                                                    (name, "Name"),
                                                    (email, "Email"),
                                                    (password, "Password"),
                                                    (password_again,
                                                     "Password (again)"))
                        if not item]
            templates.bullets(wfile, *problems)
            templates.paragraph(
                wfile,
                "Use the back-button of your browser to try again.")
        templates.footer(wfile)
Exemple #6
0
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     if user:
         templates.header(wfile)
         templates.title(wfile, 'Modify user account "%s"' % user.username)
         templates.bullets(
             wfile,
             'Supplying a new password is optional.')
         templates.modify_user_form(wfile, self.path, user.name, user.email)
         templates.footer(wfile)
     else:
         self.redirect(Login.path, self.path)
Exemple #7
0
 def _search_form(self, wfile, values):
     templates.bullets(
         wfile,
         'All criteria are combined with "And".',
         'Blank fields are ignored.',
         'Searches are case insensitive.',
         'The "regex" fields are for advanced searches '
         '(and may be ignored).')
     templates.search_form(wfile, self.path, values,
                           [""] + list(self.application.statuses),
                           self.application.priorities,
                           self.application.resolutions,
                           self.application.categories,
                           self.application.keywords,
                           self.application.versions)
Exemple #8
0
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     if user:
         templates.header(wfile)
         templates.title(wfile, "History")
         templates.bullets(
             wfile,
             '<a href="/changes">Recent changes</a> made to bugs</a>,'
             ' including addition of new bugs.',
             '<a href="/progress">Daily  progress</a>, as indicated'
             ' by changes in the number of bugs in each status</a>.')
         templates.footer(wfile)
     else:
         values["next"] = self.path
         path = lib.join_url(Login.path, values)
         self.redirect(path)
Exemple #9
0
    def _pretty_print_search(self, wfile, criteria, values):

        def clean_name(s):
            s = s.replace("regex", "(regex)")
            s = s.replace("_", " ")
            return s.capitalize()
        
        bullets = []
        for k,v in criteria.iteritems():
            bullets.append("%s = %s" % (clean_name(k),v))

        copy_of_values = values.copy()
        copy_of_values["refine"] = "yes"
        url = lib.html_entity_escape(lib.join_url(self.path, copy_of_values))
        bullets.append('<a href="%s">Refine search</a>' % url)

        templates.bullets(wfile, *bullets)
Exemple #10
0
 def _show_new(self, session_id, wfile, sort_by, order):
     if not sort_by:
         sort_by = "category"
     if not order:
         order = "ascending"
     search = application.Search(
         ("bug_id", "category", "reported_in", "title"),
         sort_by, order, status="new")
     self.application.search(session_id, search)
     templates.title(wfile, "All new bugs (%d)" % len(search.rows))
     if search.rows:
         templates.bullets(
             wfile,
             "Bugs that are new and need to be reviewed.")
         url = lib.join_url(self.path, {"status": "new"})
         templates.table_of_bugs(wfile, url, search)
     else:
         templates.paragraph(wfile, "There are no new bugs.")
Exemple #11
0
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     if user:
         templates.header(wfile)
         templates.title(wfile, "Add new bug")
         templates.bullets(
             wfile,
             'Fill in as many fields as possible and '
             'press the "Submit" button.',
             'You must provide at least a title and a description.',
             'Use new values (e.g. for version) if <em>and only if</em> '
             'the available ones are unsuitable.')
         templates.new_bug_form(wfile, self.path,
                                self.application.versions,
                                self.application.categories,
                                self.application.keywords)
         templates.footer(wfile)
     else:
         self.redirect(Login.path, self.path)
Exemple #12
0
 def _show_closed(self, session_id, wfile, sort_by, order):
     if not sort_by:
         sort_by = "tested_ok_in"
     if not order:
         order = "ascending"
     search = application.Search(
         ("bug_id", "priority", "resolution", "category", "tested_ok_in", "title"),
         sort_by, order, status="closed")
     self.application.search(session_id, search)
     templates.title(wfile, "All closed bugs (%d)" % len(search.rows))
     if search.rows:
         templates.bullets(
             wfile,
             "Bugs which require no further action.")
         url = lib.join_url(self.path, {"status": "closed"})
         templates.table_of_bugs(wfile, url, search)
     else:
         templates.paragraph(wfile,
                             "There are no closed bugs.")
Exemple #13
0
 def _show_reviewed(self, session_id, wfile, sort_by, order):
     if not sort_by:
         sort_by = "priority"
     if not order:
         order = "descending"
     search = application.Search(
         ("bug_id", "priority", "category", "reported_in", "title"),
         sort_by, order, status="reviewed")
     self.application.search(session_id, search)
     templates.title(wfile, "All reviewed bugs (%d)" % len(search.rows))
     if search.rows:
         templates.bullets(
             wfile,
             "Bugs that are ready to be scheduled.")
         url = lib.join_url(self.path, {"status": "reviewed"})
         templates.table_of_bugs(wfile, url, search)
     else:
         templates.paragraph(wfile,
                             "There are no bugs in the reviewed state.")
Exemple #14
0
 def handle_get(self, session_id, values, wfile):
     templates.header(wfile)
     templates.title(wfile, "Help")
     if config.Project.help:
         templates.bullets(
             wfile,
             'Site-specific help is available '
             '<a href="%s">here</a>.' % config.Project.help)
     else:
         templates.bullets(
             wfile,
             '<em>No site-specific help has been configured.</em>')
     templates.title(wfile, "About")
     templates.paragraph(
         wfile,
         "Midge is a system for tracking bugs found during the "
         "commercial development of a software product. It is "
         "particularly suited to a process for which the filing, "
         "managing, fixing, and testing are all undertaken by "
         "different roles in a trusted environment.")
     templates.paragraph(
         wfile,
         "Midge aims to be consistent, self-explanatory, powerful "
         "enough to efficiently manage thousands of bugs, require no "
         "administration, and be bug-free!")
     templates.paragraph(
         wfile,
         'Midge is released under the terms of the '
         '<a href="http://www.gnu.org/licenses/gpl.txt">'
         'GNU General Public License.</a>')
     templates.paragraph(
         wfile,
         "See <a href=\"http://midge.sourceforge.net\">"
         "http://midge.sourceforge.net</a> for more "
         "information, releases, <em>etc</em>.")
     templates.footer(wfile)
Exemple #15
0
 def test_bullets(self):
     """Check bullets"""
     wfile = self.get_wfile()
     templates.bullets(wfile, ["item1", "item2"])
     self.assert_(self.is_well_formed(wfile))