Changeset 2523
- Timestamp:
- 02/04/10 08:43:14 (6 weeks ago)
- Location:
- branches/0.9/pylucid_project/pylucid_plugins/blog
- Files:
-
- 3 modified
-
preference_forms.py (modified) (2 diffs)
-
templates/blog/summary.html (modified) (2 diffs)
-
views.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/pylucid_project/pylucid_plugins/blog/preference_forms.py
r2349 r2523 2 2 3 3 from django import forms 4 from django.utils.translation import ugettext as _4 from django.utils.translation import ugettext_lazy as _ 5 5 6 6 from pylucid_project.utils.site_utils import SitePreselectPreference … … 10 10 11 11 class BlogPrefForm(SitePreselectPreference, DBPreferencesBaseForm): 12 max_anonym_count = forms.IntegerField( 13 initial=10, min_value=1, 14 help_text=_( 15 "The maximal numbers of blog entries, displayed together" 16 " for anonymous users" 17 ), 18 ) 19 max_user_count = forms.IntegerField( 20 initial=30, min_value=1, 21 help_text=_( 22 "The maximal numbers of blog entries, displayed together" 23 " for logged in PyLucid users." 24 ), 25 ) 12 26 class Meta: 13 27 app_label = 'blog' -
branches/0.9/pylucid_project/pylucid_plugins/blog/templates/blog/summary.html
r2443 r2523 7 7 8 8 {% if not entries %}no blog entry exists{% endif %} 9 {% for entry in entries %}9 {% for entry in entries.object_list %} 10 10 <fieldset class="entry"> 11 11 <legend class="headline"> … … 34 34 {% endfor %} 35 35 </div> 36 37 <div class="pagination"> 38 {% if entries.has_previous %} 39 <a href="?page={{ entries.previous_page_number }}" title="{% trans "< goto previous page" %}" class="previous">⋘ {% trans "previous" %}</a> 40 {% endif %} 41 42 <span class="pagelist"> 43 {% for entry in entries.paginator.page_range %} 44 {% if entry == entries.number %} 45 <strong>{{ entry }}</strong> 46 {% else %} 47 <a href="?page={{ entry }}">{{ entry }}</a> 48 {% endif %} 49 {% endfor %} 50 </span> 51 52 {% if entries.has_next %} 53 <a href="?page={{ entries.next_page_number }}" title="{% trans "goto next page >" %}" class="next">{% trans "next" %} ⋙</a> 54 {% endif %} 55 </div> 36 56 {% endblock content %} -
branches/0.9/pylucid_project/pylucid_plugins/blog/views.py
r2449 r2523 39 39 from django.views.decorators.csrf import csrf_protect 40 40 from django.contrib.comments.views.comments import post_comment 41 from django.core.paginator import Paginator, InvalidPage, EmptyPage 41 42 42 from pylucid .decorators import render_to43 from pylucid_project.apps.pylucid.decorators import render_to 43 44 44 from blog.models import BlogEntry 45 from pylucid_project.pylucid_plugins.blog.models import BlogEntry 46 from pylucid_project.pylucid_plugins.blog.preference_forms import BlogPrefForm 45 47 46 48 # from django-tagging … … 87 89 Display summary list with all blog entries. 88 90 """ 91 # Get all blog entries, that the current user can see 89 92 queryset = BlogEntry.on_site 90 93 queryset = _filter_blog_entries(request, queryset) 94 95 # Get number of entries allowed by the users see on a page. 96 pref_form = BlogPrefForm() 97 preferences = pref_form.get_preferences() 98 if request.user.is_anonymous(): 99 max_count = preferences.get("max_anonym_count", 10) 100 else: 101 max_count = preferences.get("max_user_count", 30) 102 103 # Show max_count entries per page 104 paginator = Paginator(queryset, max_count) 105 106 # Make sure page request is an int. If not, deliver first page. 107 try: 108 page = int(request.GET.get('page', '1')) 109 except ValueError: 110 page = 1 111 112 # If page request (9999) is out of range, deliver last page of results. 113 try: 114 entries = paginator.page(page) 115 except (EmptyPage, InvalidPage): 116 entries = paginator.page(paginator.num_pages) 117 91 118 context = { 92 "entries": queryset,119 "entries": entries, 93 120 "tag_cloud": _get_tag_cloud(request), 94 121 "CSS_PLUGIN_CLASS_NAME": settings.PYLUCID.CSS_PLUGIN_CLASS_NAME,