Permalink
Browse files

edit tags

  • Loading branch information...
1 parent 14d9ede commit 1f73105f1b81dc01c0b9e44959c3e4fbecddc742 Baiju M committed Feb 9, 2011
Showing with 70 additions and 0 deletions.
  1. +23 −0 py3k/packages.py
  2. +8 −0 py3k/templates/package_details.html
  3. +39 −0 py3k/templates/tag_edit.html
View
@@ -29,6 +29,7 @@
from .model import Distribution
from .model import Comment
+from .model import Tag
from .application import app
from .application import db
@@ -43,6 +44,26 @@
def make_external(url):
return urljoin(request.url_root, "project/%s"%url)
+@app.route('/project/<name>/tag/save', methods=['POST'])
+def save_tag(name):
+ tags = list(set(request.form['tags'].split()))
+ result = Distribution.query.filter_by(name=name).first()
+ Tag.query.filter_by(distribution_id=result.id).delete()
+ for tagname in tags:
+ tag = Tag()
+ tag.name = tagname
+ tag.distribution_id = result.id
+ db.session.add(tag)
+
+ db.session.commit()
+ return redirect(url_for('packages_details', name=name))
+
+@app.route('/project/<name>/tag/edit')
+def tag_edit(name):
+ result = Distribution.query.filter_by(name=name).first()
+ tags = Tag.query.filter_by(distribution_id=result.id)
+ existing_tags = ' '.join([x.name for x in tags])
+ return render_template('tag_edit.html', tags=tags, result=result, existing_tags=existing_tags)
@app.route('/project/<name>/recent.atom')
def recent_project_comment_feed(name):
@@ -106,11 +127,13 @@ def packages_details(name):
if result is None:
return redirect(url_for('search_package', name=name, page=1))
comments = Comment.query.filter_by(distribution_id=result.id).order_by(db.desc(Comment.datetime))
+ tags = Tag.query.filter_by(distribution_id=result.id)
return render_template('package_details.html',
result=result,
comments=comments,
get_status=get_status,
time_delta=pretty_date,
+ tags=tags,
captcha_key=get_captcha_key())
@@ -39,6 +39,14 @@ <h4 style="color: #243F00">Find out all the third party libraries supported by P
<dd>{{ result.summary }}</dd>
</dl>
+<h3>Tags</h3>
+
+{% for tag in tags %}
+ {{ tag.name }}
+{% endfor %}
+<br />
+<a href="{{ url_for('tag_edit', name=result.name) }}">Edit</a>
+
<h3>Comments</h3>
{% for comment in comments %}
@@ -0,0 +1,39 @@
+{% extends "layout.html" %}
+{% block link %}
+<link href="{{ url_for('recent_project_comment_feed', name=result.name) }}"
+ rel="alternate"
+ title="Recent Comments"
+ type="application/atom+xml" />
+{% endblock %}
+
+{% block body %}
+
+<h2>Want to use Python 3 for your next project ?</h2>
+
+<h4 style="color: #243F00">Find out all the third party libraries supported by Python 3! You can
+also submit feedback about its compatibility with Python 3.</h4>
+
+<div>
+
+ <form action="{{ url_for('packages') }}" method=post>
+ <input onfocus="if(this.value == 'Search Distros') {this.value = ''}" style="opacity:0.4;font-size: 15pt" type=text name=pkgname size=20 value="Search Distros" />
+ <input style="font-size: 18pt" type=submit value="Search" />
+ <a style="text-decoration: underline" href="{{ url_for('packages') }}">Browse All</a>
+ </form>
+
+</div>
+<p>
+</p>
+<p>
+ <form action="{{ url_for('save_tag', name=result.name) }}" method=post>
+ <input type=text name=tags size=30 value="{{ existing_tags }}" /> <br/>
+ <input type=submit value="Save" />
+ </form>
+
+</p>
+
+<p>
+
+</p>
+
+{% endblock %}

0 comments on commit 1f73105

Please sign in to comment.