Changeset 74 for bitstructures/trunk/substructure/views.py
- Timestamp:
- 05/28/08 20:22:40 (7 months ago)
- Files:
-
- 1 modified
-
bitstructures/trunk/substructure/views.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bitstructures/trunk/substructure/views.py
r73 r74 5 5 from django.contrib.sites.models import Site 6 6 from django.conf import settings 7 from bitstructures.substructure.models import Entry 7 from bitstructures.substructure.models import Entry, Tag, EntryTag 8 8 from bitstructures.substructure.codeblocks import MarkdownCodeblocksParser 9 9 … … 94 94 return render_to_response('substructure/all.html', data) 95 95 96 def tagged_with(request, tag_name): 97 tag = get_object_or_404(Tag, name=tag_name) 98 data = get_context_data(request) 99 data['tag'] = tag 100 data['entry_list'] = get_published_entries_with_tag(tag) 101 return render_to_response('substructure/tagged-with.html', data) 102 103 def get_published_entries_with_tag(tag): 104 entrytags = EntryTag.objects.select_related().filter(tag=tag) 105 entry_list = [] 106 for entrytag in entrytags: 107 entry = entrytag.entry 108 if entry.is_published: 109 entry_list.append(entry) 110 return entry_list 111 96 112 def robots_txt(request): 97 113 return HttpResponse(render_to_string('substructure/robots.txt'), … … 107 123 data = { 'MEDIA_URL': settings.MEDIA_URL } 108 124 data['num_published_entries'] = get_published_entries().count() 109 if user_can_change_entry(request):110 data['user_can_change_entry'] = True111 data['drafts'] = get_drafts()112 125 return data 113 114 def user_can_change_entry(request):115 return request.user.has_perm('change_entry')116 117 def get_drafts():118 return Entry.objects.filter(date_published__isnull=True).order_by('title')
