Esempio n. 1
0
File: locations.py Progetto: p/midge
 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)
Esempio n. 2
0
File: locations.py Progetto: p/midge
 def _add_bug(self, session_id, wfile, post_data):
     new_version = post_data.pop("new_version", None)
     if new_version:
         post_data["version"] = new_version
     new_category = post_data.pop("new_category", None)
     if new_category:
         post_data["category"] = new_category
     new_keyword = post_data.pop("new_keyword", None)
     if new_keyword:
         post_data["keyword"] = new_keyword
     try:
         bug_id = self.application.add_bug(session_id, **post_data)
         templates.title(wfile, "Successfuly added new bug")
         templates.paragraph(
             wfile,
             'You have justed created new bug, number '
             '%s.' % bug_id)
         templates.possible_actions(
             wfile,
             ("/new", "Add another bug"),
             ("/view?bug_id=%s" % bug_id,
              "View the newly created Bug %s" % bug_id),
             ("/home", "Home"))
     except application.InvalidValueException:
         templates.title(wfile, "Failed to add new bug!")
         templates.paragraph(
             wfile,
             'One of the new values you have entered is invalid. '
             'Use the back-button of your browser to correct.')
Esempio n. 3
0
File: locations.py Progetto: p/midge
 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)
Esempio n. 4
0
File: locations.py Progetto: p/midge
    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)
Esempio n. 5
0
File: locations.py Progetto: p/midge
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     if user:
         self.application.logout(session_id)
         self.redirect(Home.path)
     else:
         templates.header(wfile)
         templates.title(wfile, "You were not logged-in!")
         templates.paragraph(
             wfile,
             "If you wish, you can go to the main screen "
             "in order to log in as a new user.")
         templates.possible_actions(wfile, ("home", "Home"))
         templates.footer(wfile)
Esempio n. 6
0
File: locations.py Progetto: p/midge
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     templates.header(wfile)
     templates.title(wfile, "Create a new user account")
     if user:
         templates.paragraph(
             wfile,
             'Note that you are already logged in as '
             '<b>%s</b> with a username of <b>%s</b>.' %
             (user.name, user.username))
         templates.paragraph(
             wfile,
             'It is unlikely that you wish to create a new user account, '
             'as this is normally performed by the new user. '
             'However if you really need to create a new account, '
             'fill in the following form and click the '
             '"Create account" button.')
     else:
         templates.paragraph(
             wfile,
             'If you are sure that you do not already have a user account, '
             'fill in the following form and click the '
             '"Create account" button.')
         templates.paragraph(
             wfile,
             'Note that the Username must be unique, and so you '
             'will not be allowed to create a new account with an existing '
             'Username.')
     templates.add_user_form(wfile, self.path)
     templates.footer(wfile)
Esempio n. 7
0
File: locations.py Progetto: p/midge
 def handle_post(self, session_id, values, post_data, wfile):
     user = self.application.get_user(session_id)
     if user:
         templates.header(wfile)
         if self._form_complete(post_data):
             self._add_bug(session_id, wfile, post_data)
         else:
             templates.title(wfile, "Failed to add new bug!")
             templates.paragraph(
                 wfile,
                 "You have not filled in enough fields. "
                 "Use the back-button of your browser to correct this.")
         templates.footer(wfile)
     else:
         self.redirect(Login.path, self.path)
Esempio n. 8
0
File: locations.py Progetto: p/midge
 def handle_post(self, session_id, values, post_data, wfile):
     user = self.application.get_user(session_id)
     if user:
         templates.header(wfile, "Bug %s" % post_data.get("bug_id"))
         try:
             self._make_changes(session_id, user, post_data, wfile)
         except application.InvalidValueException:
             templates.title(wfile, "Unable to change bug!")
             templates.paragraph(
                 wfile,
                 'One of the new values you have entered is invalid. '
                 'Use the back-button of your browser to correct.')
         templates.footer(wfile)
     else:
         self.redirect(Login.path, lib.join_url(self.path, values))
Esempio n. 9
0
File: locations.py Progetto: p/midge
 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.")
Esempio n. 10
0
File: locations.py Progetto: p/midge
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     username = values.get("username", None)
     templates.header(wfile)
     templates.title(wfile, "Email password")
     if username and self.application.email_password(username):
         templates.paragraph(
             wfile,
             "The password associated with the username "
             "<b>%s</b> " % username +
             "has been sent to the email address for that account.")
     else:
         templates.paragraph(
             wfile,
             "Sorry, your password has not been succesfuly "
             "emailed to you. Either midge is not configured correctly "
             "or your account does not contain a valid email address.")
     templates.footer(wfile)
Esempio n. 11
0
File: locations.py Progetto: p/midge
 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.")
Esempio n. 12
0
File: locations.py Progetto: p/midge
 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.")
Esempio n. 13
0
File: locations.py Progetto: p/midge
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     if user:
         templates.header(wfile)
         templates.title(wfile, "Home")
         templates.paragraph(
             wfile,
             'You are logged in as '
             '<b>%s</b> with a username of <b>%s</b>.' %
             (user.name, user.username))
         templates.paragraph(
             wfile,
             "You will be automatically logged-out after "
             "any (long) period of inactivity.")
         templates.possible_actions(wfile,
                                    ("logout", "Logout"),
                                    ("modifyuser", "Modify user account"))
         templates.footer(wfile)
     else:
         templates.header(wfile)
         templates.title(wfile, "Home")
         templates.paragraph(
             wfile,
             "Either login with an existing username, "
             "or create a new account if you are a new user.")
         templates.possible_actions(wfile,
                                    ("login", "Login"),
                                    ("adduser",
                                     "Create a new user account"))
         templates.footer(wfile)
Esempio n. 14
0
File: locations.py Progetto: p/midge
 def handle_post(self, session_id, values, post_data, wfile):
     next_location = values.pop("next", None) or Home.path
     username = post_data.get("username", None)
     password = post_data.get("password", None)
     if username and password and \
            self.application.login(session_id, username, password):
         path = lib.join_url(next_location, values)
         self.redirect(path)
     else:
         user = self.application.get_user(session_id)
         templates.header(wfile)
         templates.title(wfile, "Login failed!")
         if username:
             templates.paragraph(
                 wfile,
                 "You entered an incorrect password for user of username "
                 "<b>%s</b>." % username)
             templates.paragraph(
                 wfile,
                 "Use the back-button of your browser to try again, "
                 "or click below to request that your password be emailed "
                 "to you.")
             templates.possible_actions(
                 wfile,
                 ("emailpassword?username=%s" % username, 
                  "Email me my password"))
         else:
             templates.paragraph(
                 wfile,
                 "You did not provide a username. "
                 "Use the back-button of your browser to try again.")
         templates.footer(wfile)
Esempio n. 15
0
File: locations.py Progetto: p/midge
    def _search(self, session_id, wfile, values):
        sort_by = values.pop("sort_by", "bug_id")
        order = values.pop("order", "ascending")

        criteria = {}
        columns = ["bug_id", "title"]
        for key, value in values.items():
            if value:
                if key.endswith("_column"):
                    columns.append(key[:-len("_column")])
                else:
                    criteria[key] = value
        
        search = application.Search(columns, sort_by, order, **criteria)
        try:
            self.application.search(session_id, search)
            templates.title(wfile, "Search result (%d)" % len(search.rows))
            self._pretty_print_search(wfile, criteria, values)
            if search.rows:
                url = lib.join_url(self.path, values)
                templates.table_of_bugs(wfile, url, search)
            else:
                templates.paragraph(
                    wfile,
                    "No bugs match these criteria!")
        except application.InvalidSearchException, e:
            templates.title(wfile, "Invalid search criteria!")
            templates.paragraph(
                wfile,
                "Use the back-button of your browser "
                "to correct your search.")
            templates.paragraph(
                wfile,
                "Malformed regex expressions are a probable cause. "
                "For example, mismatched parentheses.")
Esempio n. 16
0
File: locations.py Progetto: p/midge
 def handle_get(self, session_id, values, wfile):
     if "next" not in values:
         values["next"] = Home.path
     user = self.application.get_user(session_id)
     templates.header(wfile)
     templates.title(wfile, "User login")
     if user:
         templates.paragraph(
             wfile,
             'Note that you are already logged in as '
             '<b>%s</b> with a username of <b>%s</b>.' %
             (user.name, user.username))
         templates.paragraph(
             wfile,
             'To change user, enter a new username and password and click '
             'the "Login" button.')
         templates.login_form(wfile, self.path, self.application.usernames)
     else:
         path = lib.join_url(self.path, values)
         templates.paragraph(
             wfile,
             'If you have not yet created a user account, '
             'do so now.')
         templates.possible_actions(wfile,
                                    ("adduser", "Create new account"))
         templates.login_form(wfile, path, self.application.usernames)
     templates.footer(wfile)
Esempio n. 17
0
File: locations.py Progetto: p/midge
 def handle_get(self, session_id, values, wfile):
     user = self.application.get_user(session_id)
     if user:
         bug_id = values.get('bug_id')
         if bug_id:
             templates.header(wfile, "Bug %s" % bug_id)
             try:
                 bug = self.application.get_bug(session_id, bug_id)
                 templates.title(wfile, bug.title)
                 self._show_status_and_comments_and_form(wfile, bug)
             except application.NoSuchBugException:
                 templates.title(wfile, "No such Bug!")
                 templates.paragraph(
                     wfile,
                     'No bug with number = "%s" exists. ' % bug_id)
         else:
             templates.header(wfile)
             templates.title(wfile, "View particular bug")
             templates.paragraph(
                 wfile,
                 'To view a particular bug, enter the bug '
                 'number in the the "Find bug" box and either click '
                 'the "Go" button or press return.')
             templates.paragraph(
                 wfile,
                 '(The "Find bug" box may be found in the header and '
                 'the footer of every page.)')
         templates.footer(wfile)
     else:
         values["next"] = self.path
         path = lib.join_url(Login.path, values)
         self.redirect(path)
Esempio n. 18
0
File: locations.py Progetto: p/midge
 def handle_post(self, session_id, values, post_data, wfile):
     name = post_data.get("name", None)
     email = post_data.get("email", None)
     password = post_data.get("password", None)
     new_password = post_data.get("new_password", None)
     new_password_again = post_data.get("new_password_again", None)
     
     user = self.application.get_user(session_id)
     if user:
         if user.authenticate(password):
             if name:
                 user.name = name
             if email:
                 user.email = email
             templates.header(wfile)
             templates.title(wfile, "User account details changed ok")
             if new_password == new_password_again:
                 if new_password:
                     user.password = new_password
                     templates.paragraph(
                         wfile,
                         "Note that you have changed your "
                         "account to use a <em>new password</em>, "
                         "which must be used from now on.")
             elif new_password or new_password_again:
                 templates.paragraph(
                     wfile,
                     "Note that your password has <em>not</em> "
                     "been changed as the two new passwords you "
                     "provided do not match.")
             templates.paragraph(
                 wfile, "Continue to the home page:")
             templates.possible_actions(wfile, ("/home", "Home"))
         else:
             templates.header(wfile)
             templates.title(wfile, "Failed to change account details!")
             templates.paragraph(
                 wfile,
                 "You failed to authenticate yourself by typing an "
                 "incorrect password. Use the "
                 "back-button of your browser to try again.")
         templates.footer(wfile)
     else:
         self.redirect(Login.path, self.path)
Esempio n. 19
0
File: locations.py Progetto: p/midge
 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)
Esempio n. 20
0
 def test_paragraph(self):
     """Check paragraph"""
     wfile = self.get_wfile()
     templates.paragraph(wfile, "a paragraph")
     self.assert_(self.is_well_formed(wfile))