Permalink
Browse files

Just for two different endpoints for the paginator, why keep two

seperate templates!
  • Loading branch information...
1 parent 38278f7 commit 8a6d6880bae96607f1f533a42dd10ce7b05b5b01 @kra3 kra3 committed Mar 10, 2011
Showing with 50 additions and 84 deletions.
  1. +8 −2 py3k/packages.py
  2. +42 −1 py3k/templates/search_package.html
  3. +0 −81 py3k/templates/show_package.html
View
@@ -118,7 +118,12 @@ def add_comment(name):
@app.route('/search/<name>/+<int:page>')
def search_package(name, page=1):
result = Distribution.query.filter(Distribution.name.like("%%%s%%"%name)).paginate(page)
- return render_template('search_package.html', page_obj=result, searchname=name)
+ return render_template('search_package.html',
+ page_obj=result,
+ end_point='search_package',
+ no_comments_packages=no_comments_packages,
+ captcha_key=get_captcha_key(),
+ searchname=name)
@app.route('/project/<name>')
@@ -145,7 +150,8 @@ def packages(page=1):
else: # for browse all
result = Distribution.query.order_by(Distribution.name).paginate(page)
no_comments_packages = db.session.query(Distribution).outerjoin(Comment).filter(Comment.distribution_id==None).limit(5)
- return render_template('show_package.html',
+ return render_template('search_package.html',
no_comments_packages=no_comments_packages,
+ end_point='packages',
captcha_key=get_captcha_key(),
page_obj=result)
@@ -18,7 +18,7 @@
</div>
{% endmacro %}
- {{ render_pagination(page_obj, 'search_package') }}
+ {{ render_pagination(page_obj, end_point) }}
<table id="myTable">
<thead>
@@ -38,3 +38,44 @@
</table>
{% endblock %}
+
+
+{% block trypkg %}
+ <ul>
+ <li>
+ {% for distribution in no_comments_packages %}
+ <a href="{{ url_for('packages_details', name=distribution.name) }}">
+ {{ distribution.name }}</a>
+ {% endfor %}
+ </li>
+ </ul>
+{% endblock %}
+
+{% block newprj %}
+ <form action="{{ url_for('save_new_project') }}" method=post>
+ <p>
+ <label for="prjname">Project Name</label>
+ <input id="prjname" name='projectname' placeholder="Project name">
+ </p>
+ <p>
+ <label for="homepg">Homepage</label>
+ <input id="homepg" type='url' name='home_page' placeholder="http://">
+ </p>
+ <p>
+ <label for="auth">Authors</label>
+ <input id="auth" name='author' placeholder="Author(s)">
+ </p>
+ <p>
+ <label for="summary">Summary</label>
+ <textarea id="summary" name='summary' placeholder="Some cool information about your wonderful project..." rows="6" cols="60"></textarea>
+ </p>
+ <p>
+ <label for="cap">Enter the letters here:</label>
+ <input id="cap" name='captchavalue'>
+ <img src="{{ url_for('captcha', key=captcha_key) }}" />
+ </p>
+ <input type=hidden name=captchakey value={{ captcha_key }}>
+ <p><input value="Submit" type="submit"></p>
+ </form>
+{% endblock %}
+
@@ -1,81 +0,0 @@
-{% extends "layout.html" %}
-
-{% block body %}
-
- {% macro render_pagination(pagination, endpoint) %}
- <div class=pagination style="font-size: 14pt;text-align:center">
- {%- for page in pagination.iter_pages() %}
- {% if page %}
- {% if page != pagination.page %}
- <a href="{{ url_for(endpoint, page=page) }}">{{ page }}</a>
- {% else %}
- <strong>{{ page }}</strong>
- {% endif %}
- {% else %}
- <span class=ellipsis>...</span>
- {% endif %}
- {%- endfor %}
- </div>
- {% endmacro %}
-
- {{ render_pagination(page_obj, 'packages') }}
-
-
- <table id="myTable">
- <thead>
- <tr>
- <th>Distribution</th>
- <th>Description</th>
- </tr>
- </thead>
- <tbody>
- {%- for item in page_obj.items %}
- <tr class="{{ loop.cycle('odd', 'even') }}">
- <td><a href="{{ url_for('packages_details', name=item.name) }}">{{ item.name }}</a></td>
- <td> {{ item.summary }} </td>
- </tr>
- {%- endfor %}
- <tbody>
- </table>
-
-{% endblock %}
-
-{% block trypkg %}
- <ul>
- <li>
- {% for distribution in no_comments_packages %}
- <a href="{{ url_for('packages_details', name=distribution.name) }}">
- {{ distribution.name }}</a>
- {% endfor %}
- </li>
- </ul>
-{% endblock %}
-
-{% block newprj %}
- <form action="{{ url_for('save_new_project') }}" method=post>
- <p>
- <label for="prjname">Project Name</label>
- <input id="prjname" name='projectname' placeholder="Project name">
- </p>
- <p>
- <label for="homepg">Homepage</label>
- <input id="homepg" type='url' name='home_page' placeholder="http://">
- </p>
- <p>
- <label for="auth">Authors</label>
- <input id="auth" name='author' placeholder="Author(s)">
- </p>
- <p>
- <label for="summary">Summary</label>
- <textarea id="summary" name='summary' placeholder="Some cool information about your wonderful project..." rows="6" cols="60"></textarea>
- </p>
- <p>
- <label for="cap">Enter the letters here:</label>
- <input id="cap" name='captchavalue'>
- <img src="{{ url_for('captcha', key=captcha_key) }}" />
- </p>
- <input type=hidden name=captchakey value={{ captcha_key }}>
- <p><input value="Submit" type="submit"></p>
- </form>
-{% endblock %}
-

0 comments on commit 8a6d688

Please sign in to comment.