Merge remote branch 'remotes/jwandborg/feature_362-simple_comments-acts_on_feedback'

Conflicts:
	mediagoblin/templates/mediagoblin/user_pages/media.html
This commit is contained in:
Christopher Allan Webber 2011-07-02 14:39:35 -05:00
commit 2110408f44
3 changed files with 13 additions and 22 deletions

View File

@ -23,7 +23,6 @@ from mediagoblin.auth import lib as auth_lib
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.db import migrations from mediagoblin.db import migrations
from mediagoblin.db.util import DESCENDING, ObjectId from mediagoblin.db.util import DESCENDING, ObjectId
from mediagoblin.util import Pagination
################### ###################
# Custom validators # Custom validators
@ -109,23 +108,12 @@ class MediaEntry(Document):
migration_handler = migrations.MediaEntryMigration migration_handler = migrations.MediaEntryMigration
def main_mediafile(self): def get_comments(self):
pass return self.db.MediaComment.find({
def get_comments(self, page):
cursor = self.db.MediaComment.find({
'media_entry': self['_id']}).sort('created', DESCENDING) 'media_entry': self['_id']}).sort('created', DESCENDING)
pagination = Pagination(page, cursor) def main_mediafile(self):
comments = pagination() pass
data = list()
for comment in comments:
comment['author'] = self.db.User.find_one({
'_id': comment['author']})
data.append(comment)
return (data, pagination)
def generate_slug(self): def generate_slug(self):
self['slug'] = util.slugify(self['title']) self['slug'] = util.slugify(self['title'])

View File

@ -57,6 +57,7 @@
{% if comments %} {% if comments %}
{% for comment in comments %} {% for comment in comments %}
{% set comment_author = comment.author() %}
<div class="comment_wrapper" id="comment-{{ comment['_id'] }}"> <div class="comment_wrapper" id="comment-{{ comment['_id'] }}">
<div class="comment_content"> <div class="comment_content">
{% autoescape False %} {% autoescape False %}
@ -65,8 +66,8 @@
</div> </div>
<div class="comment_author">&mdash; <div class="comment_author">&mdash;
<a href="{{ request.urlgen('mediagoblin.user_pages.user_home', <a href="{{ request.urlgen('mediagoblin.user_pages.user_home',
user = comment['author']['username']) }}"> user = comment_author['username']) }}">
{{ comment['author']['username'] }}</a> at {{ comment_author['username'] }}</a> at
<!--</div> <!--</div>
<div class="comment_datetime">--> <div class="comment_datetime">-->
<a href="#comment-{{ comment['_id'] }}"> <a href="#comment-{{ comment['_id'] }}">

View File

@ -82,17 +82,19 @@ def user_gallery(request, page):
'media_entries': media_entries, 'media_entries': media_entries,
'pagination': pagination}) 'pagination': pagination})
MEDIA_COMMENTS_PER_PAGE = 50
@get_user_media_entry @get_user_media_entry
@uses_pagination @uses_pagination
def media_home(request, media, **kwargs): def media_home(request, media, page, **kwargs):
""" """
'Homepage' of a MediaEntry() 'Homepage' of a MediaEntry()
""" """
comment_form = user_forms.MediaCommentForm(request.POST) pagination = Pagination(page, media.get_comments(), MEDIA_COMMENTS_PER_PAGE)
comments = pagination()
(comments, pagination) = media.get_comments(kwargs.get('page')) comment_form = user_forms.MediaCommentForm(request.POST)
return render_to_response( return render_to_response(
request, request,