Userpages assumed someone was logged in.
by/for/of:me used the logged-in user rather than the owner and depended on pylons.
h.flash(u'This username is not valid.')
return self.register()
h.flash(u'This username is not valid.')
return self.register()
+ if username in ['me']:
+ h.flash(u'This username is reserved.')
+ return self.register()
+
# Create db records
user = User(name=username, display_name=username)
user.identity_urls.append(IdentityURL(url=identity_url))
# Create db records
user = User(name=username, display_name=username)
user.identity_urls.append(IdentityURL(url=identity_url))
return self.save()
c.query = request.params.get('query', '')
return self.save()
c.query = request.params.get('query', '')
- c.artwork = parse(c.query).all()
+ c.artwork = parse(c.query, me=c.user).all()
return render('/index.mako')
# TODO: login required
return render('/index.mako')
# TODO: login required
c.art = h.get_object_or_404(Art, id=art_id)
tag_string = request.params.get('tags', '')
c.art = h.get_object_or_404(Art, id=art_id)
tag_string = request.params.get('tags', '')
- add_tags(c.art, tag_string, c.user)
+ add_tags(
+ art=c.art,
+ tag_string=tag_string,
+ adding_user=c.user,
+ me=c.user,
+ )
# Add or remove tags
redirect(url('show_art', id=c.art.id))
# Add or remove tags
redirect(url('show_art', id=c.art.id))
except NoResultFound:
abort(404)
except NoResultFound:
abort(404)
- rels = UserRelationship.query.filter_by(
- user_id=c.user.id,
- target_user_id=c.this_user.id,
- ).all()
+ if c.user:
+ rels = UserRelationship.query.filter_by(
+ user_id=c.user.id,
+ target_user_id=c.this_user.id,
+ ).all()
- c.relationships = [_.type for _ in rels]
+ c.relationships = [_.type for _ in rels]
return render('/users/view.mako')
return render('/users/view.mako')
try:
c.user = User.query.get(session['user_id'])
except:
try:
c.user = User.query.get(session['user_id'])
except:
pass
def __call__(self, environ, start_response):
pass
def __call__(self, environ, start_response):
from dbhelpers import find_or_create
import re
from dbhelpers import find_or_create
import re
-from pylons import c
-
-def parse(search_string):
+def parse(search_string, me):
"""Parses a search query, and returns a query object on Art.
Queries can contain:
- Regular tags: foo
- User relations: by:kalu, of:eevee, for:ootachi
"""Parses a search query, and returns a query object on Art.
Queries can contain:
- Regular tags: foo
- User relations: by:kalu, of:eevee, for:ootachi
+ - User relations relative to some user: by:me
+ Note that this necessitates a `me` parameter.
Later:
- Negative versions of anything above: -by:eevee, -dongs
Later:
- Negative versions of anything above: -by:eevee, -dongs
# This is a special tag; at the moment, by/for/of to indicate
# related users
prefix, tag = tag.split(':', 1)
# This is a special tag; at the moment, by/for/of to indicate
# related users
prefix, tag = tag.split(':', 1)
- if tag == 'me':
- tag = c.user.name
- # XXX what to do if this fails? abort? return empty query?
- target_user = User.get_by(name=tag)
+ if tag == 'me':
+ target_user = me
+ else:
+ # XXX what to do if this fails? abort? return empty query?
+ target_user = User.get_by(name=tag)
if prefix == 'by':
rel = ArtUserType.BY
if prefix == 'by':
rel = ArtUserType.BY
-def add_tags(art, tag_string, user):
+def add_tags(art, tag_string, adding_user, me):
"""Takes a string that looks like a tag query, and effectively modifies the
art's tags to match it.
"""
"""Takes a string that looks like a tag query, and effectively modifies the
art's tags to match it.
"""
% if c.this_user == c.user:
## Nothing
<% pass %>\
% if c.this_user == c.user:
## Nothing
<% pass %>\
${h.form(url(controller='user_settings', action='rel_toggle', name=c.user.name.lower()), method='POST')}
<p>
<input type="hidden" name="target_user" value="${c.this_user.id}">
${h.form(url(controller='user_settings', action='rel_toggle', name=c.user.name.lower()), method='POST')}
<p>
<input type="hidden" name="target_user" value="${c.this_user.id}">
<input type="hidden" name="add_remove" value="add">
<input type="submit" value="Watch">
% endif
<input type="hidden" name="add_remove" value="add">
<input type="submit" value="Watch">
% endif
% endif
<%! from floof.lib.tags import parse %>
% for gallery in c.this_user.primary_page.galleries:
<h2>${gallery.string}</h2>
% endif
<%! from floof.lib.tags import parse %>
% for gallery in c.this_user.primary_page.galleries:
<h2>${gallery.string}</h2>
-${macros.thumbs(parse(gallery.search.string))}
+${macros.thumbs(parse(gallery.search.string, me=c.this_user))}