コード例 #1
0
ファイル: locations.py プロジェクト: 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)
コード例 #2
0
ファイル: locations.py プロジェクト: p/midge
 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)
コード例 #3
0
ファイル: locations.py プロジェクト: 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)
コード例 #4
0
ファイル: locations.py プロジェクト: 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)
コード例 #5
0
ファイル: locations.py プロジェクト: 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)
コード例 #6
0
ファイル: locations.py プロジェクト: 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)
コード例 #7
0
ファイル: locations.py プロジェクト: 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)
コード例 #8
0
ファイル: locations.py プロジェクト: 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)
コード例 #9
0
ファイル: locations.py プロジェクト: 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)
コード例 #10
0
ファイル: templates_test.py プロジェクト: p/midge
    def test_header(self):
        """Check header"""
        wfile = self.get_wfile()
        templates.header(wfile)
        wfile.write("</div></body></html>")
        self.assert_(self.is_well_formed(wfile))

        wfile = self.get_wfile()
        templates.header(wfile, "extra title")
        wfile.write("</div></body></html>")
        self.assert_(self.is_well_formed(wfile))
コード例 #11
0
ファイル: locations.py プロジェクト: 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, '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)
コード例 #12
0
ファイル: locations.py プロジェクト: 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)
コード例 #13
0
ファイル: locations.py プロジェクト: 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)
コード例 #14
0
ファイル: locations.py プロジェクト: 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))
コード例 #15
0
ファイル: locations.py プロジェクト: 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, "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)
コード例 #16
0
ファイル: locations.py プロジェクト: p/midge
 def handle_get(self, session_id, values, wfile):
     self._reload_if_url_can_be_simplified(values)
     user = self.application.get_user(session_id)
     if user:
         templates.header(wfile)
         if len(values) == 0:
             templates.title(wfile, "Search for bugs")
             self._search_form(wfile, values)
         elif "refine" in values:
             templates.title(wfile, "Refine search for bugs")
             self._search_form(wfile, values)
         else:
             self._search(session_id, wfile, values)
         templates.footer(wfile)
     else:
         self.redirect(Login.path, lib.join_url(self.path, values))
コード例 #17
0
ファイル: locations.py プロジェクト: 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)
コード例 #18
0
ファイル: locations.py プロジェクト: 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)
コード例 #19
0
ファイル: locations.py プロジェクト: 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, "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)
コード例 #20
0
ファイル: locations.py プロジェクト: 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)