Dot-Notation for "_id"
Note: Migrations can't use "Dot Notation"! Migrations run on pymongo, not mongokit. So they can't use the "Dot Notation". This isn't really a big issue, as migrations are anyway quite mongo specific.
This commit is contained in:
parent
7cbddc96a8
commit
eabe6b678a
@ -109,7 +109,7 @@ def send_verification_email(user, request):
|
|||||||
'verification_url': EMAIL_VERIFICATION_TEMPLATE.format(
|
'verification_url': EMAIL_VERIFICATION_TEMPLATE.format(
|
||||||
host=request.host,
|
host=request.host,
|
||||||
uri=request.urlgen('mediagoblin.auth.verify_email'),
|
uri=request.urlgen('mediagoblin.auth.verify_email'),
|
||||||
userid=unicode(user['_id']),
|
userid=unicode(user._id),
|
||||||
verification_key=user['verification_key'])})
|
verification_key=user['verification_key'])})
|
||||||
|
|
||||||
# TODO: There is no error handling in place
|
# TODO: There is no error handling in place
|
||||||
@ -144,7 +144,7 @@ def send_fp_verification_email(user, request):
|
|||||||
'verification_url': EMAIL_FP_VERIFICATION_TEMPLATE.format(
|
'verification_url': EMAIL_FP_VERIFICATION_TEMPLATE.format(
|
||||||
host=request.host,
|
host=request.host,
|
||||||
uri=request.urlgen('mediagoblin.auth.verify_forgot_password'),
|
uri=request.urlgen('mediagoblin.auth.verify_forgot_password'),
|
||||||
userid=unicode(user['_id']),
|
userid=unicode(user._id),
|
||||||
fp_verification_key=user['fp_verification_key'])})
|
fp_verification_key=user['fp_verification_key'])})
|
||||||
|
|
||||||
# TODO: There is no error handling in place
|
# TODO: There is no error handling in place
|
||||||
|
@ -87,7 +87,7 @@ def register(request):
|
|||||||
user.save(validate=True)
|
user.save(validate=True)
|
||||||
|
|
||||||
# log the user in
|
# log the user in
|
||||||
request.session['user_id'] = unicode(user['_id'])
|
request.session['user_id'] = unicode(user._id)
|
||||||
request.session.save()
|
request.session.save()
|
||||||
|
|
||||||
# send verification email
|
# send verification email
|
||||||
@ -122,7 +122,7 @@ def login(request):
|
|||||||
|
|
||||||
if user and user.check_login(request.POST['password']):
|
if user and user.check_login(request.POST['password']):
|
||||||
# set up login in session
|
# set up login in session
|
||||||
request.session['user_id'] = unicode(user['_id'])
|
request.session['user_id'] = unicode(user._id)
|
||||||
request.session.save()
|
request.session.save()
|
||||||
|
|
||||||
if request.POST.get('next'):
|
if request.POST.get('next'):
|
||||||
|
@ -219,7 +219,7 @@ class MediaEntry(Document):
|
|||||||
|
|
||||||
def get_comments(self):
|
def get_comments(self):
|
||||||
return self.db.MediaComment.find({
|
return self.db.MediaComment.find({
|
||||||
'media_entry': self['_id']}).sort('created', DESCENDING)
|
'media_entry': self._id}).sort('created', DESCENDING)
|
||||||
|
|
||||||
def get_display_media(self, media_map,
|
def get_display_media(self, media_map,
|
||||||
fetch_order=common.DISPLAY_IMAGE_FETCHING_ORDER):
|
fetch_order=common.DISPLAY_IMAGE_FETCHING_ORDER):
|
||||||
@ -250,7 +250,7 @@ class MediaEntry(Document):
|
|||||||
{'slug': self['slug']})
|
{'slug': self['slug']})
|
||||||
|
|
||||||
if duplicate:
|
if duplicate:
|
||||||
self['slug'] = "%s-%s" % (self['_id'], self['slug'])
|
self['slug'] = "%s-%s" % (self._id, self['slug'])
|
||||||
|
|
||||||
def url_for_self(self, urlgen):
|
def url_for_self(self, urlgen):
|
||||||
"""
|
"""
|
||||||
@ -269,13 +269,13 @@ class MediaEntry(Document):
|
|||||||
return urlgen(
|
return urlgen(
|
||||||
'mediagoblin.user_pages.media_home',
|
'mediagoblin.user_pages.media_home',
|
||||||
user=uploader['username'],
|
user=uploader['username'],
|
||||||
media=unicode(self['_id']))
|
media=unicode(self._id))
|
||||||
|
|
||||||
def url_to_prev(self, urlgen):
|
def url_to_prev(self, urlgen):
|
||||||
"""
|
"""
|
||||||
Provide a url to the previous entry from this user, if there is one
|
Provide a url to the previous entry from this user, if there is one
|
||||||
"""
|
"""
|
||||||
cursor = self.db.MediaEntry.find({'_id': {"$gt": self['_id']},
|
cursor = self.db.MediaEntry.find({'_id': {"$gt": self._id},
|
||||||
'uploader': self['uploader'],
|
'uploader': self['uploader'],
|
||||||
'state': 'processed'}).sort(
|
'state': 'processed'}).sort(
|
||||||
'_id', ASCENDING).limit(1)
|
'_id', ASCENDING).limit(1)
|
||||||
@ -288,7 +288,7 @@ class MediaEntry(Document):
|
|||||||
"""
|
"""
|
||||||
Provide a url to the next entry from this user, if there is one
|
Provide a url to the next entry from this user, if there is one
|
||||||
"""
|
"""
|
||||||
cursor = self.db.MediaEntry.find({'_id': {"$lt": self['_id']},
|
cursor = self.db.MediaEntry.find({'_id': {"$lt": self._id},
|
||||||
'uploader': self['uploader'],
|
'uploader': self['uploader'],
|
||||||
'state': 'processed'}).sort(
|
'state': 'processed'}).sort(
|
||||||
'_id', DESCENDING).limit(1)
|
'_id', DESCENDING).limit(1)
|
||||||
|
@ -60,7 +60,7 @@ def user_may_delete_media(controller):
|
|||||||
uploader = request.db.MediaEntry.find_one(
|
uploader = request.db.MediaEntry.find_one(
|
||||||
{'_id': ObjectId(request.matchdict['media'])}).uploader()
|
{'_id': ObjectId(request.matchdict['media'])}).uploader()
|
||||||
if not (request.user['is_admin'] or
|
if not (request.user['is_admin'] or
|
||||||
request.user['_id'] == uploader['_id']):
|
request.user._id == uploader._id):
|
||||||
return exc.HTTPForbidden()
|
return exc.HTTPForbidden()
|
||||||
|
|
||||||
return controller(request, *args, **kwargs)
|
return controller(request, *args, **kwargs)
|
||||||
@ -99,7 +99,7 @@ def get_user_media_entry(controller):
|
|||||||
media = request.db.MediaEntry.find_one(
|
media = request.db.MediaEntry.find_one(
|
||||||
{'slug': request.matchdict['media'],
|
{'slug': request.matchdict['media'],
|
||||||
'state': 'processed',
|
'state': 'processed',
|
||||||
'uploader': user['_id']})
|
'uploader': user._id})
|
||||||
|
|
||||||
# no media via slug? Grab it via ObjectId
|
# no media via slug? Grab it via ObjectId
|
||||||
if not media:
|
if not media:
|
||||||
@ -107,7 +107,7 @@ def get_user_media_entry(controller):
|
|||||||
media = request.db.MediaEntry.find_one(
|
media = request.db.MediaEntry.find_one(
|
||||||
{'_id': ObjectId(request.matchdict['media']),
|
{'_id': ObjectId(request.matchdict['media']),
|
||||||
'state': 'processed',
|
'state': 'processed',
|
||||||
'uploader': user['_id']})
|
'uploader': user._id})
|
||||||
except InvalidId:
|
except InvalidId:
|
||||||
return render_404(request)
|
return render_404(request)
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
def may_edit_media(request, media):
|
def may_edit_media(request, media):
|
||||||
"""Check, if the request's user may edit the media details"""
|
"""Check, if the request's user may edit the media details"""
|
||||||
if media['uploader'] == request.user['_id']:
|
if media['uploader'] == request.user._id:
|
||||||
return True
|
return True
|
||||||
if request.user['is_admin']:
|
if request.user['is_admin']:
|
||||||
return True
|
return True
|
||||||
|
@ -57,7 +57,7 @@ def edit_media(request, media):
|
|||||||
existing_user_slug_entries = request.db.MediaEntry.find(
|
existing_user_slug_entries = request.db.MediaEntry.find(
|
||||||
{'slug': request.POST['slug'],
|
{'slug': request.POST['slug'],
|
||||||
'uploader': media['uploader'],
|
'uploader': media['uploader'],
|
||||||
'_id': {'$ne': media['_id']}}).count()
|
'_id': {'$ne': media._id}}).count()
|
||||||
|
|
||||||
if existing_user_slug_entries:
|
if existing_user_slug_entries:
|
||||||
form.slug.errors.append(
|
form.slug.errors.append(
|
||||||
@ -78,7 +78,7 @@ def edit_media(request, media):
|
|||||||
location=media.url_for_self(request.urlgen))
|
location=media.url_for_self(request.urlgen))
|
||||||
|
|
||||||
if request.user['is_admin'] \
|
if request.user['is_admin'] \
|
||||||
and media['uploader'] != request.user['_id'] \
|
and media['uploader'] != request.user._id \
|
||||||
and request.method != 'POST':
|
and request.method != 'POST':
|
||||||
messages.add_message(
|
messages.add_message(
|
||||||
request, messages.WARNING,
|
request, messages.WARNING,
|
||||||
@ -104,7 +104,7 @@ def edit_attachments(request, media):
|
|||||||
|
|
||||||
attachment_public_filepath \
|
attachment_public_filepath \
|
||||||
= mg_globals.public_store.get_unique_filepath(
|
= mg_globals.public_store.get_unique_filepath(
|
||||||
['media_entries', unicode(media['_id']), 'attachment',
|
['media_entries', unicode(media._id), 'attachment',
|
||||||
secure_filename(request.POST['attachment_file'].filename)])
|
secure_filename(request.POST['attachment_file'].filename)])
|
||||||
|
|
||||||
attachment_public_file = mg_globals.public_store.get_file(
|
attachment_public_file = mg_globals.public_store.get_file(
|
||||||
|
@ -32,7 +32,7 @@ MEDIUM_SIZE = 640, 640
|
|||||||
def create_pub_filepath(entry, filename):
|
def create_pub_filepath(entry, filename):
|
||||||
return mgg.public_store.get_unique_filepath(
|
return mgg.public_store.get_unique_filepath(
|
||||||
['media_entries',
|
['media_entries',
|
||||||
unicode(entry['_id']),
|
unicode(entry._id),
|
||||||
filename])
|
filename])
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class ProcessMedia(Task):
|
|||||||
try:
|
try:
|
||||||
process_image(entry)
|
process_image(entry)
|
||||||
except BaseProcessingFail, exc:
|
except BaseProcessingFail, exc:
|
||||||
mark_entry_failed(entry[u'_id'], exc)
|
mark_entry_failed(entry._id, exc)
|
||||||
return
|
return
|
||||||
|
|
||||||
entry['state'] = u'processed'
|
entry['state'] = u'processed'
|
||||||
|
@ -52,7 +52,7 @@ def submit_start(request):
|
|||||||
|
|
||||||
# create entry and save in database
|
# create entry and save in database
|
||||||
entry = request.db.MediaEntry()
|
entry = request.db.MediaEntry()
|
||||||
entry['_id'] = ObjectId()
|
entry._id = ObjectId()
|
||||||
entry['title'] = (
|
entry['title'] = (
|
||||||
unicode(request.POST['title'])
|
unicode(request.POST['title'])
|
||||||
or unicode(splitext(filename)[0]))
|
or unicode(splitext(filename)[0]))
|
||||||
@ -62,7 +62,7 @@ def submit_start(request):
|
|||||||
entry['description'])
|
entry['description'])
|
||||||
|
|
||||||
entry['media_type'] = u'image' # heh
|
entry['media_type'] = u'image' # heh
|
||||||
entry['uploader'] = request.user['_id']
|
entry['uploader'] = request.user._id
|
||||||
|
|
||||||
# Process the user's folksonomy "tags"
|
# Process the user's folksonomy "tags"
|
||||||
entry['tags'] = convert_to_tag_list_of_dicts(
|
entry['tags'] = convert_to_tag_list_of_dicts(
|
||||||
@ -74,7 +74,7 @@ def submit_start(request):
|
|||||||
# Now store generate the queueing related filename
|
# Now store generate the queueing related filename
|
||||||
queue_filepath = request.app.queue_store.get_unique_filepath(
|
queue_filepath = request.app.queue_store.get_unique_filepath(
|
||||||
['media_entries',
|
['media_entries',
|
||||||
unicode(entry['_id']),
|
unicode(entry._id),
|
||||||
secure_filename(filename)])
|
secure_filename(filename)])
|
||||||
|
|
||||||
# queue appropriately
|
# queue appropriately
|
||||||
@ -105,7 +105,7 @@ def submit_start(request):
|
|||||||
# conditions with changes to the document via processing code)
|
# conditions with changes to the document via processing code)
|
||||||
try:
|
try:
|
||||||
process_media.apply_async(
|
process_media.apply_async(
|
||||||
[unicode(entry['_id'])], {},
|
[unicode(entry._id)], {},
|
||||||
task_id=task_id)
|
task_id=task_id)
|
||||||
except BaseException as exc:
|
except BaseException as exc:
|
||||||
# The purpose of this section is because when running in "lazy"
|
# The purpose of this section is because when running in "lazy"
|
||||||
@ -116,7 +116,7 @@ def submit_start(request):
|
|||||||
#
|
#
|
||||||
# ... not completely the diaper pattern because the
|
# ... not completely the diaper pattern because the
|
||||||
# exception is re-raised :)
|
# exception is re-raised :)
|
||||||
mark_entry_failed(entry[u'_id'], exc)
|
mark_entry_failed(entry._id, exc)
|
||||||
# re-raise the exception
|
# re-raise the exception
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -69,10 +69,10 @@
|
|||||||
{% for comment in comments %}
|
{% for comment in comments %}
|
||||||
{% set comment_author = comment.author() %}
|
{% set comment_author = comment.author() %}
|
||||||
{% if pagination.active_id == comment._id %}
|
{% if pagination.active_id == comment._id %}
|
||||||
<div class="comment_wrapper comment_active" id="comment-{{ comment['_id'] }}">
|
<div class="comment_wrapper comment_active" id="comment-{{ comment._id }}">
|
||||||
<a name="comment" id="comment"></a>
|
<a name="comment" id="comment"></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="comment_wrapper" id="comment-{{ comment['_id'] }}">
|
<div class="comment_wrapper" id="comment-{{ comment._id }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="comment_content">{% autoescape False %}{{ comment.content_html }}
|
<div class="comment_content">{% autoescape False %}{{ comment.content_html }}
|
||||||
@ -83,7 +83,7 @@
|
|||||||
{{ comment_author['username'] }}</a>
|
{{ comment_author['username'] }}</a>
|
||||||
{% trans %}at{% endtrans %}
|
{% trans %}at{% endtrans %}
|
||||||
<a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment',
|
<a href="{{ request.urlgen('mediagoblin.user_pages.media_home.view_comment',
|
||||||
comment = comment['_id'],
|
comment = comment._id,
|
||||||
user = media.uploader().username,
|
user = media.uploader().username,
|
||||||
media = media._id) }}#comment">
|
media = media._id) }}#comment">
|
||||||
{{ comment.created.strftime("%I:%M%p %Y-%m-%d") }}
|
{{ comment.created.strftime("%I:%M%p %Y-%m-%d") }}
|
||||||
@ -114,7 +114,7 @@
|
|||||||
<div class="grid_5 omega">
|
<div class="grid_5 omega">
|
||||||
{% include "mediagoblin/utils/prev_next.html" %}
|
{% include "mediagoblin/utils/prev_next.html" %}
|
||||||
|
|
||||||
{% if media['uploader'] == request.user['_id'] or
|
{% if media['uploader'] == request.user._id or
|
||||||
request.user['is_admin'] %}
|
request.user['is_admin'] %}
|
||||||
<h3>{% trans %}Actions{% endtrans %}</h3>
|
<h3>{% trans %}Actions{% endtrans %}</h3>
|
||||||
<p>
|
<p>
|
||||||
@ -151,7 +151,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if app_config['allow_attachments']
|
{% if app_config['allow_attachments']
|
||||||
and (media['uploader'] == request.user['_id']
|
and (media['uploader'] == request.user._id
|
||||||
or request.user['is_admin']) %}
|
or request.user['is_admin']) %}
|
||||||
<p>
|
<p>
|
||||||
<a href="{{ request.urlgen('mediagoblin.edit.attachments',
|
<a href="{{ request.urlgen('mediagoblin.edit.attachments',
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{% if not user['url'] and not user['profile'] %}
|
{% if not user['url'] and not user['profile'] %}
|
||||||
{% if request.user['_id'] == user['_id'] %}
|
{% if request.user._id == user._id %}
|
||||||
<div class="grid_6 alpha empty_space">
|
<div class="grid_6 alpha empty_space">
|
||||||
<p>
|
<p>
|
||||||
{% trans %}Here's a spot to tell others about yourself.{% endtrans %}
|
{% trans %}Here's a spot to tell others about yourself.{% endtrans %}
|
||||||
@ -113,7 +113,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<div class="grid_6 alpha">
|
<div class="grid_6 alpha">
|
||||||
{% include "mediagoblin/utils/profile.html" %}
|
{% include "mediagoblin/utils/profile.html" %}
|
||||||
{% if request.user['_id'] == user['_id'] or request.user['is_admin'] %}
|
{% if request.user._id == user._id or request.user['is_admin'] %}
|
||||||
<a href="{{ request.urlgen('mediagoblin.edit.profile') }}?username={{
|
<a href="{{ request.urlgen('mediagoblin.edit.profile') }}?username={{
|
||||||
user.username }}">
|
user.username }}">
|
||||||
{%- trans %}Edit profile{% endtrans -%}
|
{%- trans %}Edit profile{% endtrans -%}
|
||||||
@ -140,7 +140,7 @@
|
|||||||
{% include "mediagoblin/utils/feed_link.html" %}
|
{% include "mediagoblin/utils/feed_link.html" %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if request.user['_id'] == user['_id'] %}
|
{% if request.user._id == user._id %}
|
||||||
<div class="grid_10 omega empty_space">
|
<div class="grid_10 omega empty_space">
|
||||||
<p>
|
<p>
|
||||||
{% trans -%}
|
{% trans -%}
|
||||||
|
@ -168,7 +168,7 @@ def test_register_views(test_app):
|
|||||||
## Make sure user is logged in
|
## Make sure user is logged in
|
||||||
request = template.TEMPLATE_TEST_CONTEXT[
|
request = template.TEMPLATE_TEST_CONTEXT[
|
||||||
'mediagoblin/user_pages/user.html']['request']
|
'mediagoblin/user_pages/user.html']['request']
|
||||||
assert request.session['user_id'] == unicode(new_user['_id'])
|
assert request.session['user_id'] == unicode(new_user._id)
|
||||||
|
|
||||||
## Make sure we get email confirmation, and try verifying
|
## Make sure we get email confirmation, and try verifying
|
||||||
assert len(mail.EMAIL_TEST_INBOX) == 1
|
assert len(mail.EMAIL_TEST_INBOX) == 1
|
||||||
@ -185,7 +185,7 @@ def test_register_views(test_app):
|
|||||||
|
|
||||||
### user should have these same parameters
|
### user should have these same parameters
|
||||||
assert parsed_get_params['userid'] == [
|
assert parsed_get_params['userid'] == [
|
||||||
unicode(new_user['_id'])]
|
unicode(new_user._id)]
|
||||||
assert parsed_get_params['token'] == [
|
assert parsed_get_params['token'] == [
|
||||||
new_user['verification_key']]
|
new_user['verification_key']]
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ def test_register_views(test_app):
|
|||||||
template.clear_test_template_context()
|
template.clear_test_template_context()
|
||||||
response = test_app.get(
|
response = test_app.get(
|
||||||
"/auth/verify_email/?userid=%s&token=total_bs" % unicode(
|
"/auth/verify_email/?userid=%s&token=total_bs" % unicode(
|
||||||
new_user['_id']))
|
new_user._id))
|
||||||
response.follow()
|
response.follow()
|
||||||
context = template.TEMPLATE_TEST_CONTEXT[
|
context = template.TEMPLATE_TEST_CONTEXT[
|
||||||
'mediagoblin/user_pages/user.html']
|
'mediagoblin/user_pages/user.html']
|
||||||
@ -269,7 +269,7 @@ def test_register_views(test_app):
|
|||||||
|
|
||||||
# user should have matching parameters
|
# user should have matching parameters
|
||||||
new_user = mg_globals.database.User.find_one({'username': 'happygirl'})
|
new_user = mg_globals.database.User.find_one({'username': 'happygirl'})
|
||||||
assert parsed_get_params['userid'] == [unicode(new_user['_id'])]
|
assert parsed_get_params['userid'] == [unicode(new_user._id)]
|
||||||
assert parsed_get_params['token'] == [new_user['fp_verification_key']]
|
assert parsed_get_params['token'] == [new_user['fp_verification_key']]
|
||||||
|
|
||||||
### The forgotten password token should be set to expire in ~ 10 days
|
### The forgotten password token should be set to expire in ~ 10 days
|
||||||
@ -280,7 +280,7 @@ def test_register_views(test_app):
|
|||||||
template.clear_test_template_context()
|
template.clear_test_template_context()
|
||||||
response = test_app.get(
|
response = test_app.get(
|
||||||
"/auth/forgot_password/verify/?userid=%s&token=total_bs" % unicode(
|
"/auth/forgot_password/verify/?userid=%s&token=total_bs" % unicode(
|
||||||
new_user['_id']), status=400)
|
new_user._id), status=400)
|
||||||
assert response.status == '400 Bad Request'
|
assert response.status == '400 Bad Request'
|
||||||
|
|
||||||
## Try using an expired token to change password, shouldn't work
|
## Try using an expired token to change password, shouldn't work
|
||||||
@ -412,7 +412,7 @@ def test_authentication_views(test_app):
|
|||||||
# Make sure user is in the session
|
# Make sure user is in the session
|
||||||
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
|
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
|
||||||
session = context['request'].session
|
session = context['request'].session
|
||||||
assert session['user_id'] == unicode(test_user['_id'])
|
assert session['user_id'] == unicode(test_user._id)
|
||||||
|
|
||||||
# Successful logout
|
# Successful logout
|
||||||
# -----------------
|
# -----------------
|
||||||
|
@ -177,7 +177,7 @@ class TestSubmission:
|
|||||||
request.urlgen('mediagoblin.user_pages.media_confirm_delete',
|
request.urlgen('mediagoblin.user_pages.media_confirm_delete',
|
||||||
# No work: user=media.uploader().username,
|
# No work: user=media.uploader().username,
|
||||||
user=self.test_user['username'],
|
user=self.test_user['username'],
|
||||||
media=media['_id']),
|
media=media._id),
|
||||||
# no value means no confirm
|
# no value means no confirm
|
||||||
{})
|
{})
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ class TestSubmission:
|
|||||||
request.urlgen('mediagoblin.user_pages.media_confirm_delete',
|
request.urlgen('mediagoblin.user_pages.media_confirm_delete',
|
||||||
# No work: user=media.uploader().username,
|
# No work: user=media.uploader().username,
|
||||||
user=self.test_user['username'],
|
user=self.test_user['username'],
|
||||||
media=media['_id']),
|
media=media._id),
|
||||||
{'confirm': 'y'})
|
{'confirm': 'y'})
|
||||||
|
|
||||||
response.follow()
|
response.follow()
|
||||||
@ -208,7 +208,7 @@ class TestSubmission:
|
|||||||
# Does media entry still exist?
|
# Does media entry still exist?
|
||||||
assert_false(
|
assert_false(
|
||||||
request.db.MediaEntry.find(
|
request.db.MediaEntry.find(
|
||||||
{'_id': media['_id']}).count())
|
{'_id': media._id}).count())
|
||||||
|
|
||||||
def test_malicious_uploads(self):
|
def test_malicious_uploads(self):
|
||||||
# Test non-suppoerted file with non-supported extension
|
# Test non-suppoerted file with non-supported extension
|
||||||
|
@ -53,7 +53,7 @@ class Pagination(object):
|
|||||||
cursor = copy.copy(self.cursor)
|
cursor = copy.copy(self.cursor)
|
||||||
|
|
||||||
for (doc, increment) in izip(cursor, count(0)):
|
for (doc, increment) in izip(cursor, count(0)):
|
||||||
if doc['_id'] == jump_to_id:
|
if doc._id == jump_to_id:
|
||||||
self.page = 1 + int(floor(increment / self.per_page))
|
self.page = 1 + int(floor(increment / self.per_page))
|
||||||
|
|
||||||
self.active_id = jump_to_id
|
self.active_id = jump_to_id
|
||||||
|
@ -45,7 +45,7 @@ def user_home(request, page):
|
|||||||
{'user': user})
|
{'user': user})
|
||||||
|
|
||||||
cursor = request.db.MediaEntry.find(
|
cursor = request.db.MediaEntry.find(
|
||||||
{'uploader': user['_id'],
|
{'uploader': user._id,
|
||||||
'state': 'processed'}).sort('created', DESCENDING)
|
'state': 'processed'}).sort('created', DESCENDING)
|
||||||
|
|
||||||
pagination = Pagination(page, cursor)
|
pagination = Pagination(page, cursor)
|
||||||
@ -78,7 +78,7 @@ def user_gallery(request, page):
|
|||||||
return render_404(request)
|
return render_404(request)
|
||||||
|
|
||||||
cursor = request.db.MediaEntry.find(
|
cursor = request.db.MediaEntry.find(
|
||||||
{'uploader': user['_id'],
|
{'uploader': user._id,
|
||||||
'state': 'processed'}).sort('created', DESCENDING)
|
'state': 'processed'}).sort('created', DESCENDING)
|
||||||
|
|
||||||
pagination = Pagination(page, cursor)
|
pagination = Pagination(page, cursor)
|
||||||
@ -135,8 +135,8 @@ def media_post_comment(request, media):
|
|||||||
assert request.method == 'POST'
|
assert request.method == 'POST'
|
||||||
|
|
||||||
comment = request.db.MediaComment()
|
comment = request.db.MediaComment()
|
||||||
comment['media_entry'] = media['_id']
|
comment['media_entry'] = media._id
|
||||||
comment['author'] = request.user['_id']
|
comment['author'] = request.user._id
|
||||||
comment['content'] = unicode(request.POST['comment_content'])
|
comment['content'] = unicode(request.POST['comment_content'])
|
||||||
comment['content_html'] = cleaned_markdown_conversion(comment['content'])
|
comment['content_html'] = cleaned_markdown_conversion(comment['content'])
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ def media_confirm_delete(request, media):
|
|||||||
location=media.url_for_self(request.urlgen))
|
location=media.url_for_self(request.urlgen))
|
||||||
|
|
||||||
if ((request.user[u'is_admin'] and
|
if ((request.user[u'is_admin'] and
|
||||||
request.user[u'_id'] != media.uploader()[u'_id'])):
|
request.user._id != media.uploader()._id)):
|
||||||
messages.add_message(
|
messages.add_message(
|
||||||
request, messages.WARNING,
|
request, messages.WARNING,
|
||||||
_("You are about to delete another user's media. "
|
_("You are about to delete another user's media. "
|
||||||
@ -207,7 +207,7 @@ def atom_feed(request):
|
|||||||
return render_404(request)
|
return render_404(request)
|
||||||
|
|
||||||
cursor = request.db.MediaEntry.find({
|
cursor = request.db.MediaEntry.find({
|
||||||
'uploader': user['_id'],
|
'uploader': user._id,
|
||||||
'state': 'processed'}) \
|
'state': 'processed'}) \
|
||||||
.sort('created', DESCENDING) \
|
.sort('created', DESCENDING) \
|
||||||
.limit(ATOM_DEFAULT_NR_OF_UPDATED_ITEMS)
|
.limit(ATOM_DEFAULT_NR_OF_UPDATED_ITEMS)
|
||||||
@ -251,7 +251,7 @@ def processing_panel(request):
|
|||||||
#
|
#
|
||||||
# Make sure we have permission to access this user's panel. Only
|
# Make sure we have permission to access this user's panel. Only
|
||||||
# admins and this user herself should be able to do so.
|
# admins and this user herself should be able to do so.
|
||||||
if not (user[u'_id'] == request.user[u'_id']
|
if not (user._id == request.user._id
|
||||||
or request.user.is_admin):
|
or request.user.is_admin):
|
||||||
# No? Let's simply redirect to this user's homepage then.
|
# No? Let's simply redirect to this user's homepage then.
|
||||||
return redirect(
|
return redirect(
|
||||||
@ -260,12 +260,12 @@ def processing_panel(request):
|
|||||||
|
|
||||||
# Get media entries which are in-processing
|
# Get media entries which are in-processing
|
||||||
processing_entries = request.db.MediaEntry.find(
|
processing_entries = request.db.MediaEntry.find(
|
||||||
{'uploader': user['_id'],
|
{'uploader': user._id,
|
||||||
'state': 'processing'}).sort('created', DESCENDING)
|
'state': 'processing'}).sort('created', DESCENDING)
|
||||||
|
|
||||||
# Get media entries which have failed to process
|
# Get media entries which have failed to process
|
||||||
failed_entries = request.db.MediaEntry.find(
|
failed_entries = request.db.MediaEntry.find(
|
||||||
{'uploader': user['_id'],
|
{'uploader': user._id,
|
||||||
'state': 'failed'}).sort('created', DESCENDING)
|
'state': 'failed'}).sort('created', DESCENDING)
|
||||||
|
|
||||||
# Render to response
|
# Render to response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user