Commits

Anonymous committed a384524

add needed thing for new view

  • Participants
  • Parent commits 8325c40

Comments (0)

Files changed (7)

File buildout.cfg

      M2Crypto
      WSGIUtils
      BeautifulSoup
-     pypi
+     pypi
+
+[nose]
+recipe = pbp.recipe.noserunner
             res = []
         return Result(None, res, self._User_Packages)
 
+    _User_Details_Packages = FastResultRow('''name stable_version version author
+                  author_email maintainer maintainer_email home_page
+                  license summary description description_html keywords
+                  platform requires_python download_url''')
+    def user_packages_details(self, user):
+        ''' Retrieve package info for all packages of a user
+        '''
+        cursor = self.get_cursor()
+        sql = '''select packages.name as name, stable_version, version, author,
+                  author_email, maintainer, maintainer_email, home_page,
+                  license, summary, description, description_html, keywords,
+                  platform, requires_python, download_url
+                 from packages, releases, roles
+                 where roles.user_name=%s and package_name is not NULL
+                 and packages.name=releases.name 
+                 and roles.package_name=packages.name
+                 order by lower(package_name)'''
+        safe_execute(cursor, sql, (user,))
+        res = cursor.fetchall()
+        if res is None:
+            res = []
+        return Result(None, res, self._User_Details_Packages)
+
     #
     # Trove
     #

File templates/your_packages.pt

+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:tal="http://xml.zope.org/namespaces/tal"
+  xmlns:metal="http://xml.zope.org/namespaces/metal"
+  metal:use-macro="standard_template/macros/page">
+  <metal:fill fill-slot="body">
+    <tal:let define="packages python:app.store.user_packages_details(app.username)">
+      <table class="list">
+	<tbody>
+	  <tr>
+	    <th>Package</th>
+	    <th>Description</th>
+	  </tr>
+	  <tr tal:repeat="package packages">
+	    <td>                            
+	      <a tal:attributes="href python: app.link_action('pkg_edit', name=package[0])"
+		 tal:content="python:package[0]">package</a>
+	    </td>
+	    <td>
+	      <div tal:content="python:package[10]">&nbsp;</div>
+	    </td>
+	  </tr>
+	</tbody>
+      </table>
+    </tal:let>
+  </metal:fill>
+</html>

File utils/__init__.py

Empty file added.

File utils/string.py

+import re
+
+# poor man's markup heuristics so we don't have to use <PRE>,
+# for when rst didn't work on the text...
+br_patt = re.compile(" *\r?\n\r?(?= +)")
+p_patt = re.compile(" *\r?\n(\r?\n)+")
+
+def newline_to_br(text):
+    text = re.sub(br_patt, "<br />", text)
+    return re.sub(p_patt, "\n<p>\n", text)
+
+def path2str(path):
+    return " :: ".join(path)
+
+def str2path(s):
+    return [ node.strip() for node in s.split("::") ]
+

File webui/core.py

         ('submit_form', 'Package submission'),
         ('list_classifiers', 'List trove classifiers'),
         ('index', 'List packages'),
+        ('your_packages', 'Your packages'),
         ('rss', 'RSS (last 40 updates)'),
         ('role_form', 'Admin'),
     )
                 raise Unauthorised, "Incomplete registration; check your email"
 
         # handle the action
-        if action in 'debug home browse rss index search submit doap display_pkginfo submit_pkg_info remove_pkg pkg_edit verify submit_form display register_form user_form forgotten_password_form user password_reset role role_form list_classifiers login logout files file_upload show_md5 doc_upload claim openid openid_return dropid rate comment addcomment delcomment clear_auth addkey delkey lasthour'.split():
+        if action in ['debug', 'home', 'browse', 'rss', 'index', 'search', 
+                      'submit', 'doap', 'display_pkginfo', 'submit_pkg_info', 
+                      'remove_pkg', 'pkg_edit', 'verify', 'submit_form', 
+                      'display', 'register_form', 'user_form', 
+                      'forgotten_password_form', 'user', 'password_reset', 
+                      'role', 'role_form', 'list_classifiers', 
+                      'login', 'logout', 'files', 'file_upload', 'show_md5', 
+                      'doc_upload', 'claim', 'openid', 'openid_return', 
+                      'dropid', 'rate', 'comment', 'addcomment', 'delcomment', 
+                      'clear_auth', 'addkey', 'delkey', 'lasthour', 'your_packages']:
             getattr(self, action)()
         else:
             #raise NotFound, 'Unknown action'
         stdout = p.communicate()[0]
         if p.returncode != 0:
             raise FormError, "Key processing failed. Please contact the administrator. Detail: "+stdout
+
+    def your_packages(self):
+        packages_details = self.store.user_packages_details(self.username)
+        self.write_template('your_packages.pt', 
+                            title="Your packages",
+                            name="your_packages",
+                            packages_details=packages_details)

File webui/messages.py

+import smtplib
+
+# email sent to user indicating how they should complete their registration
+rego_message = '''Subject: Complete your Cheese Shop registration
+From: %(admin)s
+To: %(email)s
+
+To complete your registration of the user "%(name)s" with the python module
+index, please visit the following URL:
+
+  %(url)s?:action=user&otk=%(otk)s
+
+'''
+
+# password change request email
+password_change_message = '''Subject: Cheese Shop password change request
+From: %(admin)s
+To: %(email)s
+
+Someone, perhaps you, has requested that the password be changed for your
+username, "%(name)s". If you wish to proceed with the change, please follow
+the link below:
+
+  %(url)s?:action=password_reset&email=%(email)s
+
+You should then receive another email with the new password.
+
+'''
+
+# password reset email - indicates what the password is now
+password_message = '''Subject: Cheese Shop password has been reset
+From: %(admin)s
+To: %(email)s
+
+Your login is: %(name)s
+Your password is now: %(password)s
+'''
+
+unauth_message = '''
+<p>If you are a new user, <a href="%(url_path)s?:action=register_form">please
+register</a>.</p>
+<p>If you have forgotten your password, you can have it
+<a href="%(url_path)s?:action=forgotten_password_form">reset for you</a>.</p>
+'''
+
+comment_message = '''Subject: New comment on %(package)s
+From: PyPI operators <%(admin)s>
+To: %(email)s
+Reply-To: %(replyto)s
+
+[REPLIES TO THIS MESSAGE WILL NOT GO TO THE COMMENTER]
+%(author)s has made the following comment on your package.
+
+%(comment)s
+
+You can read all comments on %(url)s.
+'''
+
+def comment_email(store, package, version, author, comment, add_recipients):
+    emails = set()
+    recipients = [r['user_name'] for r in store.get_package_roles(package)] + add_recipients
+    for r in recipients:
+        email = store.get_user(r)['email']
+        if email:
+            emails.add(email)
+    info = {
+        'package': package,
+        'admin': store.config.adminemail,
+        'replyto': store.config.replyto,
+        'author': author,
+        'email': ','.join(emails),
+        'comment': comment,
+        'url': '%s/%s/%s' % (store.config.url, package, version),
+        }
+    smtp = smtplib.SMTP(store.config.mailhost)
+    smtp.sendmail(store.config.adminemail, list(emails), comment_message % info)