# along with this program. If not, see <http://www.gnu.org/licenses/>.
from functools import wraps
-from mediagoblin.db.models import User
from mediagoblin.decorators import require_active_login
from mediagoblin.tools.response import json_response
from mediagoblin.decorators import oauth_required, require_active_login
from mediagoblin.api.decorators import user_has_privilege
-from mediagoblin.db.models import User, MediaEntry, MediaComment, Activity
+from mediagoblin.db.models import User, LocalUser, MediaEntry, MediaComment, Activity
from mediagoblin.tools.federation import create_activity, create_generator
from mediagoblin.tools.routing import extract_url_arguments
from mediagoblin.tools.response import redirect, json_response, json_error, \
can be found then this function returns a (None, None).
"""
username = request.matchdict["username"]
- user = User.query.filter_by(username=username).first()
+ user = User.query.filter(LocalUser.username==username).first()
if user is None:
return None, None
def uploads_endpoint(request):
""" Endpoint for file uploads """
username = request.matchdict["username"]
- requested_user = User.query.filter_by(username=username).first()
+ requested_user = User.query.filter(LocalUser.username==username).first()
if requested_user is None:
return json_error("No such 'user' with id '{0}'".format(username), 404)
inbox: allows you to pass a query in to limit inbox scope
"""
username = request.matchdict["username"]
- user = User.query.filter_by(username=username).first()
+ user = User.query.filter(LocalUser.username==username).first()
if user is None:
return json_error("No such 'user' with id '{0}'".format(username), 404)
def feed_endpoint(request, outbox=None):
""" Handles the user's outbox - /api/user/<username>/feed """
username = request.matchdict["username"]
- requested_user = User.query.filter_by(username=username).first()
+ requested_user = User.query.filter(LocalUser.username==username).first()
# check if the user exists
if requested_user is None:
username, host = resource.split("@", 1)
# Now lookup the user
- user = User.query.filter_by(username=username).first()
+ user = User.query.filter(LocalUser.username==username).first()
if user is None:
return json_error(
from mediagoblin import mg_globals
from mediagoblin.tools.crypto import get_timed_signer_url
-from mediagoblin.db.models import User, Privilege
+from mediagoblin.db.models import LocalUser, Privilege
from mediagoblin.tools.mail import (normalize_email, send_email,
email_debug_message)
from mediagoblin.tools.template import render_template
def basic_extra_validation(register_form, *args):
- users_with_username = User.query.filter_by(
+ users_with_username = LocalUser.query.filter_by(
username=register_form.username.data).count()
- users_with_email = User.query.filter_by(
+ users_with_email = LocalUser.query.filter_by(
email=register_form.email.data).count()
extra_validation_passes = True
def create_basic_user(form):
- user = User()
+ user = LocalUser()
user.username = form.username.data
user.email = form.email.data
user.save()
use the old ActivityIntermediator to the new temparay fields which use the
new GenericForeignKey.
"""
+
metadata = MetaData(bind=db.bind)
activity_table = inspect_table(metadata, "core__activities")
ai_table = inspect_table(metadata, "core__activity_intermediators")
from mediagoblin import mg_globals as mgg
from mediagoblin import messages
-from mediagoblin.db.models import MediaEntry, User, MediaComment, AccessToken
+from mediagoblin.db.models import MediaEntry, LocalUser, MediaComment, AccessToken
from mediagoblin.tools.response import (
redirect, render_404,
render_user_banned, json_response)
def active_user_from_url(controller):
- """Retrieve User() from <user> URL pattern and pass in as url_user=...
+ """Retrieve LocalUser() from <user> URL pattern and pass in as url_user=...
Returns a 404 if no such active user has been found"""
@wraps(controller)
def wrapper(request, *args, **kwargs):
- user = User.query.filter_by(username=request.matchdict['user']).first()
+ user = LocalUser.query.filter_by(username=request.matchdict['user']).first()
if user is None:
return render_404(request)
"""
@wraps(controller)
def wrapper(request, *args, **kwargs):
- creator_id = request.db.User.query.filter_by(
+ creator_id = request.db.LocalUser.query.filter_by(
username=request.matchdict['user']).first().id
if not (request.user.has_privilege(u'admin') or
request.user.id == creator_id):
"""
@wraps(controller)
def wrapper(request, *args, **kwargs):
- user = User.query.filter_by(username=request.matchdict['user']).first()
+ user = LocalUser.query.filter_by(username=request.matchdict['user']).first()
if not user:
raise NotFound()
"""
@wraps(controller)
def wrapper(request, *args, **kwargs):
- user = request.db.User.query.filter_by(
+ user = request.db.LocalUser.query.filter_by(
username=request.matchdict['user']).first()
if not user:
"""
@wraps(controller)
def wrapper(request, *args, **kwargs):
- user = request.db.User.query.filter_by(
+ user = request.db.LocalUser.query.filter_by(
username=request.matchdict['user']).first()
if not user:
request.access_token = AccessToken.query.filter_by(token=token).first()
if request.access_token is not None and request.user is None:
user_id = request.access_token.user
- request.user = User.query.filter_by(id=user_id).first()
+ request.user = LocalUser.query.filter_by(id=user_id).first()
return controller(request, *args, **kwargs)
convert_to_tag_list_of_dicts, media_tags_as_string)
from mediagoblin.tools.url import slugify
from mediagoblin.db.util import check_media_slug_used, check_collection_slug_used
-from mediagoblin.db.models import User, Client, AccessToken, Location
+from mediagoblin.db.models import User, LocalUser, Client, AccessToken, Location
import mimetypes
if request.method == 'POST' and form.validate():
new_email = form.new_email.data
- users_with_email = User.query.filter_by(
- email=new_email).count()
+ users_with_email = User.query.filter(
+ LocalUser.email==new_email
+ ).count()
if users_with_email:
form.new_email.errors.append(
import six
+from mediagoblin.db.models import LocalUser
from mediagoblin.gmg_commands import util as commands_util
from mediagoblin.submit.lib import (
submit_media, get_upload_file_limits,
app = commands_util.setup_app(args)
# get the user
- user = app.db.User.query.filter_by(username=args.username.lower()).first()
+ user = app.db.User.query.filter(
+ LocalUser.username==args.username.lower()
+ ).first()
if user is None:
print("Sorry, no user by username '%s'" % args.username)
return
from six.moves.urllib.parse import urlparse
+from mediagoblin.db.models import LocalUser
from mediagoblin.gmg_commands import util as commands_util
from mediagoblin.submit.lib import (
submit_media, get_upload_file_limits,
files_uploaded, files_attempted = 0, 0
# get the user
- user = app.db.User.query.filter_by(username=args.username.lower()).first()
+ user = app.db.User.query.filter(
+ LocalUser.username==args.username.lower()
+ ).first()
if user is None:
print(_(u"Sorry, no user by username '{username}' exists".format(
username=args.username)))
import six
+from mediagoblin.db.models import LocalUser
from mediagoblin.gmg_commands import util as commands_util
from mediagoblin import auth
from mediagoblin import mg_globals
db = mg_globals.database
users_with_username = \
- db.User.query.filter_by(
- username=args.username.lower()
+ db.User.query.filter(
+ LocalUser.username==args.username.lower()
).count()
if users_with_username:
else:
# Create the user
- entry = db.User()
+ entry = db.LocalUser()
entry.username = six.text_type(args.username.lower())
entry.email = six.text_type(args.email)
entry.pw_hash = auth.gen_password_hash(args.password)
db = mg_globals.database
- user = db.User.query.filter_by(
- username=six.text_type(args.username.lower())).one()
+ user = db.User.query.filter(
+ LocalUser.username==six.text_type(args.username.lower())
+ ).one()
if user:
user.all_privileges.append(
db.Privilege.query.filter(
db = mg_globals.database
- user = db.User.query.filter_by(
- username=six.text_type(args.username.lower())).one()
+ user = db.User.query.filter(
+ LocalUser.username==six.text_type(args.username.lower())
+ ).one()
if user:
user.pw_hash = auth.gen_password_hash(args.password)
user.save()
db = mg_globals.database
- user = db.User.query.filter_by(username=args.username.lower()).first()
+ user = db.User.query.filter(
+ LocalUser.username==args.username.lower()
+ ).first()
if user:
user.delete()
print('The user %s has been deleted' % args.username)
cleaned_markdown_conversion)
from mediagoblin.db.util import check_media_slug_used, check_collection_slug_used
-from mediagoblin.db.models import User, Collection, MediaEntry
+from mediagoblin.db.models import User, Collection, MediaEntry, LocalUser
from mediagoblin.notifications import add_comment_subscription
Deletes a blog and media entries, tags associated with it.
"""
url_user = request.matchdict.get('user')
- owner_user = request.db.User.query.filter_by(username=url_user).first()
+ owner_user = request.db.User.query.filter(
+ LocalUser.username==url_user
+ ).first()
blog_slug = request.matchdict.get('blog_slug', None)
blog = get_blog_by_slug(request, blog_slug, author=owner_user.id)
blog_slug = request.matchdict.get('blog_slug', None)
url_user = request.matchdict.get('user', None)
- user = request.db.User.query.filter_by(username=url_user).first()
+ user = request.db.User.query.filter(
+ LocalUser.username=url_user
+ ).first()
blog = get_blog_by_slug(request, blog_slug, author=user.id)
if not user or not blog:
import six
from mediagoblin import mg_globals
-from mediagoblin.db.models import User, Privilege, UserBan
+from mediagoblin.db.models import User, Privilege, UserBan, LocalUser
from mediagoblin.db.base import Session
from mediagoblin.tools.mail import send_email
from mediagoblin.tools.response import redirect
privilege = Privilege.query.filter(
Privilege.privilege_name==privileges[0]).first()
user = User.query.filter(
- User.username==user).first()
+ LocalUser.username==user
+ ).first()
if privilege in user.all_privileges:
user.all_privileges.remove(privilege)
return True
privilege = Privilege.query.filter(
Privilege.privilege_name==privileges[0]).first()
user = User.query.filter(
- User.username==user).first()
+ LoclUser.username==user
+ ).first()
if privilege not in user.all_privileges:
user.all_privileges.append(privilege)
return True
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from mediagoblin.db.models import (MediaEntry, User,ReportBase, Privilege,
- UserBan)
+from mediagoblin.db.models import (MediaEntry, User, ReportBase, Privilege,
+ UserBan, LocalUser)
from mediagoblin.decorators import (require_admin_or_moderator_login,
active_user_from_url, user_has_privilege,
allow_reporting)
'''
Shows details about a particular user.
'''
- user = User.query.filter_by(username=request.matchdict['user']).first()
+ user = User.query.filter(
+ LocalUser.username==request.matchdict['user']
+ ).first()
active_reports = user.reports_filed_on.filter(
ReportBase.resolved==None).limit(5)
closed_reports = user.reports_filed_on.filter(
import six
-from mediagoblin.db.models import MediaEntry, User
+from mediagoblin.db.models import MediaEntry, User, LocalUser
from mediagoblin.plugins.archivalook.models import FeaturedMedia
from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
from mediagoblin.plugins.archivalook.models import FeaturedMedia
matches the specifications.
"""
uploader = User.query.filter(
- User.username == uploader_username).first()
+ LocalUser.username==uploader_username
+ ).first()
media = MediaEntry.query.filter(
- MediaEntry.get_uploader == uploader ).filter(
- MediaEntry.slug == slug).first()
+ MediaEntry.get_uploader == uploader ).filter(
+ MediaEntry.slug == slug).first()
return media
elif target_feature.display_type == u'primary':
target_feature.display_type = u'secondary'
target_feature.save()
-
from mediagoblin.plugins.basic_auth import forms as auth_forms
from mediagoblin.plugins.basic_auth import tools as auth_tools
from mediagoblin.auth.tools import create_basic_user
-from mediagoblin.db.models import User
+from mediagoblin.db.models import LocalUser
from mediagoblin.tools import pluginapi
from sqlalchemy import or_
from mediagoblin.tools.staticdirect import PluginStatic
def get_user(**kwargs):
username = kwargs.pop('username', None)
if username:
- user = User.query.filter(
+ user = LocalUser.query.filter(
or_(
- User.username == username,
- User.email == username,
+ LocalUser.username == username,
+ LocalUser.email == username,
)).first()
return user
from itsdangerous import BadSignature
from mediagoblin import messages
-from mediagoblin.db.models import User
+from mediagoblin.db.models import LocalUser
from mediagoblin.decorators import require_active_login
from mediagoblin.plugins.basic_auth import forms, tools
from mediagoblin.tools.crypto import get_timed_signer_url
found_by_email = '@' in fp_form.username.data
if found_by_email:
- user = User.query.filter_by(
+ user = LocalUser.query.filter_by(
email=fp_form.username.data).first()
# Don't reveal success in case the lookup happened by email address.
success_message = _("If that email address (case sensitive!) is "
"instructions on how to change your password.")
else: # found by username
- user = User.query.filter_by(
+ user = LocalUser.query.filter_by(
username=fp_form.username.data).first()
if user is None:
'index')
# check if it's a valid user id
- user = User.query.filter_by(id=int(token)).first()
+ user = LocalUser.query.filter_by(id=int(token)).first()
# no user in db
if not user:
from mediagoblin import mg_globals, messages
from mediagoblin.auth.tools import register_user
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, LocalUser
from mediagoblin.decorators import allow_registration, auth_enabled
from mediagoblin.plugins.ldap import forms
from mediagoblin.plugins.ldap.tools import LDAP
login_form.password.data)
if username:
- user = User.query.filter_by(
- username=username).first()
+ user = User.query.filter(
+ LocalUser.username==username
+ ).first()
if user:
# set up login in session
from sqlalchemy import or_
from mediagoblin.auth.tools import create_basic_user
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, LocalUser
from mediagoblin.plugins.openid.models import OpenIDUserURL
from mediagoblin.tools import pluginapi
from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
username = register_form.username.data
user = User.query.filter(
or_(
- User.username == username,
- User.email == username,
+ LocalUser.username == username,
+ LocalUser.email == username,
)).first()
if not user:
from sqlalchemy import or_
from mediagoblin.auth.tools import create_basic_user
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, LocalUser
from mediagoblin.plugins.persona.models import PersonaUserEmails
from mediagoblin.tools import pluginapi
from mediagoblin.tools.staticdirect import PluginStatic
username = register_form.username.data
user = User.query.filter(
or_(
- User.username == username,
- User.email == username,
+ LocalUser.username == username,
+ LocalUser.email == username,
)).first()
if not user:
import pytest
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, LocalUser
from mediagoblin.tests.tools import fixture_add_user
from mediagoblin.tools import template
fixture_add_user(username, **options)
def user(self, username):
- return User.query.filter(User.username == username).first()
+ return User.query.filter(LocalUser.username==username).first()
def _do_request(self, url, *context_keys, **kwargs):
template.clear_test_template_context()
import six.moves.urllib.parse as urlparse
from mediagoblin import mg_globals
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, LocalUser
from mediagoblin.tests.tools import get_app, fixture_add_user
from mediagoblin.tools import template, mail
from mediagoblin.auth import tools as auth_tools
assert 'mediagoblin/user_pages/user_nonactive.html' in template.TEMPLATE_TEST_CONTEXT
## Make sure user is in place
- new_user = mg_globals.database.User.query.filter_by(
- username=u'angrygirl').first()
+ new_user = mg_globals.database.User.query.filter(
+ LocalUser.usrname==u'angrygirl'
+ ).first()
assert new_user
## Make sure that the proper privileges are granted on registration
# assert context['verification_successful'] == True
# TODO: Would be good to test messages here when we can do so...
- new_user = mg_globals.database.User.query.filter_by(
- username=u'angrygirl').first()
+ new_user = mg_globals.database.User.query.filter(
+ LocalUser.username==u'angrygirl'
+ ).first()
assert new_user
## Verify the email activation works
'mediagoblin/user_pages/user.html']
# assert context['verification_successful'] == True
# TODO: Would be good to test messages here when we can do so...
- new_user = mg_globals.database.User.query.filter_by(
- username=u'angrygirl').first()
+ new_user = mg_globals.database.User.query.filter(
+ LocalUser.username==u'angrygirl'
+ ).first()
assert new_user
# Uniqueness checks
import six.moves.urllib.parse as urlparse
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, LocalUser
from mediagoblin.plugins.basic_auth import tools as auth_tools
from mediagoblin.tests.tools import fixture_add_user
from mediagoblin.tools import template
assert urlparse.urlsplit(res.location)[2] == '/edit/account/'
# test_user has to be fetched again in order to have the current values
- test_user = User.query.filter_by(username=u'chris').first()
+ test_user = User.query.filter(LocalUser.username==u'chris').first()
assert auth_tools.bcrypt_check_password('123456', test_user.pw_hash)
# test that the password cannot be changed if the given
'new_password': '098765',
})
- test_user = User.query.filter_by(username=u'chris').first()
+ test_user = User.query.filter(LocalUser.username==u'chris').first()
assert not auth_tools.bcrypt_check_password('098765', test_user.pw_hash)
import pytest
from mediagoblin import mg_globals
-from mediagoblin.db.models import User, MediaEntry
+from mediagoblin.db.models import User, LocalUser, MediaEntry
from mediagoblin.tests.tools import fixture_add_user, fixture_media_entry
from mediagoblin import auth
from mediagoblin.tools import template, mail
self.login(test_app)
# Make sure user exists
- assert User.query.filter_by(username=u'chris').first()
+ assert User.query.filter(LocalUser.username=u'chris').first()
res = test_app.post('/edit/account/delete/', {'confirmed': 'y'})
# Make sure user has been deleted
- assert User.query.filter_by(username=u'chris').first() == None
+ assert User.query.filter(LocalUser.username==u'chris').first() == None
#TODO: make sure all corresponding items comments etc have been
# deleted too. Perhaps in submission test?
'bio': u'I love toast!',
'url': u'http://dustycloud.org/'})
- test_user = User.query.filter_by(username=u'chris').first()
+ test_user = User.query.filter(LocalUser.username==u'chris').first()
assert test_user.bio == u'I love toast!'
assert test_user.url == u'http://dustycloud.org/'
assert urlparse.urlsplit(res.location)[2] == '/'
# Email shouldn't be saved
- email_in_db = mg_globals.database.User.query.filter_by(
- email='new@example.com').first()
- email = User.query.filter_by(username='chris').first().email
+ email_in_db = mg_globals.database.User.query.filter(
+ LocalUser.email=='new@example.com'
+ ).first()
+ email = User.query.filter(LocalUser.username=='chris').first().email
assert email_in_db is None
assert email == 'chris@example.com'
res.follow()
# New email saved?
- email = User.query.filter_by(username='chris').first().email
+ email = User.query.filter(LocalUser.username=='chris').first().email
assert email == 'new@example.com'
# test changing the url inproperly
def setup(self, test_app):
# set up new user
self.user_password = u'toast'
- self.user = fixture_add_user(password = self.user_password,
- privileges=[u'active',u'admin'])
+ self.user = fixture_add_user(
+ password = self.user_password,
+ privileges=[u'active',u'admin']
+ )
self.test_app = test_app
def login(self, test_app):
from mediagoblin import mg_globals
from mediagoblin.db.base import Session
+from mediagoblin.db.models import LocalUser
from mediagoblin.tests.tools import get_app
from mediagoblin.tools import template
ldap_plugin_app.get('/auth/logout/')
# Get user and detach from session
- test_user = mg_globals.database.User.query.filter_by(
- username=u'chris').first()
+ test_user = mg_globals.database.User.query.filter(
+ LocalUser.username==u'chris'
+ ).first()
Session.expunge(test_user)
# Log back in
from __future__ import print_function
from mediagoblin.db.base import Session
-from mediagoblin.db.models import MediaEntry, User, Privilege, Activity, \
- Generator
+from mediagoblin.db.models import MediaEntry, User, LocalUser, Privilege, \
+ Activity, Generator
from mediagoblin.tests import MGClientTestCase
from mediagoblin.tests.tools import fixture_add_user, fixture_media_entry, \
fixture_add_user(u'aeva',
privileges=[u'moderator',u'active'])
self.natalie_user = User.query.filter(
- User.username==u'natalie').first()
+ LocalUser.username==u'natalie').first()
self.aeva_user = User.query.filter(
- User.username==u'aeva').first()
+ LocalUser.username==u'aeva').first()
def test_privilege_added_correctly(self, test_app):
self._setup()
from mediagoblin.tests.tools import (fixture_add_user,
fixture_add_comment_report, fixture_add_comment)
-from mediagoblin.db.models import User, CommentReport, MediaComment, UserBan
+from mediagoblin.db.models import User, LocalUser, CommentReport, MediaComment, UserBan
from mediagoblin.tools import template, mail
from webtest import AppError
self.query_for_users()
def query_for_users(self):
- self.admin_user = User.query.filter(User.username==u'admin').first()
- self.mod_user = User.query.filter(User.username==u'moderator').first()
- self.user = User.query.filter(User.username==u'regular').first()
+ self.admin_user = User.query.filter(LocalUser.username==u'admin').first()
+ self.mod_user = User.query.filter(LocalUser.username==u'moderator').first()
+ self.user = User.query.filter(LocalUser.username==u'regular').first()
def do_post(self, data, *context_keys, **kwargs):
url = kwargs.pop('url', '/submit/')
from mediagoblin import mg_globals
from mediagoblin.db.base import Session
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, LocalUser
from mediagoblin.plugins.openid.models import OpenIDUserURL
from mediagoblin.tests.tools import get_app, fixture_add_user
from mediagoblin.tools import template
openid_plugin_app.get('/auth/logout')
# Get user and detach from session
- test_user = mg_globals.database.User.query.filter_by(
- username=u'chris').first()
+ test_user = mg_globals.database.User.query.filter(
+ LocalUser.username==u'chris'
+ ).first()
Session.expunge(test_user)
# Log back in
pytest.importorskip("requests")
from mediagoblin import mg_globals
-from mediagoblin.db.base import Session
+from mediagoblin.db.base import Session, LocalUser
from mediagoblin.db.models import Privilege
from mediagoblin.tests.tools import get_app
from mediagoblin.tools import template
persona_plugin_app.get('/auth/logout/')
# Get user and detach from session
- test_user = mg_globals.database.User.query.filter_by(
- username=u'chris').first()
+ test_user = mg_globals.database.User.query.filter(
+ LocalUser.username==u'chris'
+ ).first()
active_privilege = Privilege.query.filter(
Privilege.privilege_name==u'active').first()
test_user.all_privileges.append(active_privilege)
test_user.save()
- test_user = mg_globals.database.User.query.filter_by(
- username=u'chris').first()
+ test_user = mg_globals.database.User.query.filter(
+ LocalUser.username==u'chris'
+ ).first()
Session.expunge(test_user)
# Add another user for _test_edit_persona
from mediagoblin.tests.tools import fixture_add_user, fixture_media_entry
-from mediagoblin.db.models import User, UserBan
+from mediagoblin.db.models import User, LocalUser, UserBan
from mediagoblin.tools import template
from .resources import GOOD_JPG
return response, context_data
def query_for_users(self):
- self.admin_user = User.query.filter(User.username==u'alex').first()
- self.mod_user = User.query.filter(User.username==u'meow').first()
- self.user = User.query.filter(User.username==u'natalie').first()
+ self.admin_user = User.query.filter(LocalUser.username==u'alex').first()
+ self.mod_user = User.query.filter(LocalUser.username==u'meow').first()
+ self.user = User.query.filter(LocalUser.username==u'natalie').first()
def testUserBanned(self):
self.login(u'natalie')
from mediagoblin.tools import template
from mediagoblin.tests.tools import (fixture_add_user, fixture_media_entry,
fixture_add_comment, fixture_add_comment_report)
-from mediagoblin.db.models import (MediaReport, CommentReport, User,
+from mediagoblin.db.models import (MediaReport, CommentReport, User, LocalUser
MediaComment)
return response, context_data
def query_for_users(self):
- return (User.query.filter(User.username==u'allie').first(),
- User.query.filter(User.username==u'natalie').first())
+ return (User.query.filter(LocalUser.username==u'allie').first(),
+ User.query.filter(LocalUser.username==u'natalie').first())
def testMediaReports(self):
self.login(u'allie')
from mediagoblin.tests.tools import fixture_add_user
from .media_tools import create_av
from mediagoblin import mg_globals
-from mediagoblin.db.models import MediaEntry, User
+from mediagoblin.db.models import MediaEntry, User, LocalUser
from mediagoblin.db.base import Session
from mediagoblin.tools import template
from mediagoblin.media_types.image import ImageMediaManager
#### totally stupid.
#### Also if we found a way to make this run it should be a
#### property.
- return User.query.filter(User.username==u'chris').first()
+ return User.query.filter(LocalUser.username==u'chris').first()
def login(self):
self.test_app.post(
from webtest import TestApp
from mediagoblin import mg_globals
-from mediagoblin.db.models import User, MediaEntry, Collection, MediaComment, \
+from mediagoblin.db.models import User, LocalUser, MediaEntry, Collection, MediaComment, \
CommentSubscription, CommentNotification, Privilege, CommentReport, Client, \
RequestToken, AccessToken, Activity, Generator
from mediagoblin.tools import testing
def fixture_add_user(username=u'chris', password=u'toast',
privileges=[], wants_comment_notification=True):
# Reuse existing user or create a new one
- test_user = User.query.filter_by(username=username).first()
+ test_user = User.query.filter(LocalUser.username==username).first()
if test_user is None:
- test_user = User()
+ test_user = LocalUser()
test_user.username = username
test_user.email = username + u'@example.com'
if password is not None:
test_user.save()
# Reload
- test_user = User.query.filter_by(username=username).first()
+ test_user = User.query.filter(LocalUser.username==username).first()
# ... and detach from session:
Session.expunge(test_user)
# If they've set it override the actor from the obj.
activity.actor = actor.id if isinstance(actor, User) else actor
-
activity.generator = generator.id
activity.save()
from mediagoblin import messages, mg_globals
from mediagoblin.db.models import (MediaEntry, MediaTag, Collection,
- CollectionItem, User, Activity)
+ CollectionItem, LocalUser, Activity)
from mediagoblin.tools.response import render_to_response, render_404, \
redirect, redirect_obj
from mediagoblin.tools.text import cleaned_markdown_conversion
@user_not_banned
@uses_pagination
def user_home(request, page):
- """'Homepage' of a User()"""
- user = User.query.filter_by(username=request.matchdict['user']).first()
+ """'Homepage' of a LocalUser()"""
+ user = LocalUser.query.filter_by(username=request.matchdict['user']).first()
if not user:
return render_404(request)
elif not user.has_privilege(u'active'):
@active_user_from_url
@uses_pagination
def user_gallery(request, page, url_user=None):
- """'Gallery' of a User()"""
+ """'Gallery' of a LocalUser()"""
tag = request.matchdict.get('tag', None)
cursor = MediaEntry.query.filter_by(
uploader=url_user.id,
"""
generates the atom feed with the newest images
"""
- user = User.query.filter_by(
+ user = LocalUser.query.filter_by(
username = request.matchdict['user']).first()
if not user or not user.has_privilege(u'active'):
return render_404(request)
"""
generates the atom feed with the newest images from a collection
"""
- user = User.query.filter_by(
+ user = LocalUser.query.filter_by(
username = request.matchdict['user']).first()
if not user or not user.has_privilege(u'active'):
return render_404(request)
Show to the user what media is still in conversion/processing...
and what failed, and why!
"""
- user = User.query.filter_by(username=request.matchdict['user']).first()
+ user = LocalUser.query.filter_by(username=request.matchdict['user']).first()
# TODO: XXX: Should this be a decorator?
#
# Make sure we have permission to access this user's panel. Only
"""
# Get the user object.
username = request.matchdict["username"]
- user = User.query.filter_by(username=username).first()
+ user = LocalUser.query.filter_by(username=username).first()
activity_id = request.matchdict["id"]