Permalink
Browse files

Moar work on getting 1.5-ready.

  • Loading branch information...
nicksergeant committed Mar 24, 2013
1 parent a74b63e commit fb0142f2491acdaf5287f329118106a64d1b22a3
Showing with 21 additions and 20 deletions.
  1. +3 βˆ’2 requirements.txt
  2. +15 βˆ’15 snipts/api.py
  3. +1 βˆ’1 snipts/search_indexes.py
  4. +2 βˆ’2 templates/base.html
@@ -14,7 +14,7 @@ gunicorn
lxml
parsedatetime
psycopg2
pyelasticsearch
pyelasticsearch==0.3
Pygments
python-memcached
python-postmark
@@ -24,6 +24,7 @@ simplejson
South
Werkzeug
git+https://github.com/toastdriven/django-haystack.git@master#egg=django-haystack
hg+https://bitbucket.org/ubernostrum/django-registration#egg=django-registration
git+git://github.com/toastdriven/django-haystack.git#egg=django-haystack
git+git://github.com/mintchaos/typogrify.git#egg=typogrify
@@ -23,20 +23,20 @@
class FavoriteValidation(Validation):
def is_valid(self, bundle, request=None):
def is_valid(self, bundle):
errors = {}
snipt = bundle.data['snipt']
if Favorite.objects.filter(user=request.user, snipt=snipt).count():
if Favorite.objects.filter(user=bundle.request.user, snipt=snipt).count():
errors['duplicate'] = 'User has already favorited this snipt.'
return errors
class UserProfileValidation(Validation):
def is_valid(self, bundle, request=None):
def is_valid(self, bundle):
errors = {}
if not request.user.profile.is_pro:
if not bundle.request.user.profile.is_pro:
return 'You must be a Pro to change these settings.'
for field in bundle.data:
@@ -258,18 +258,18 @@ def dehydrate(self, bundle):
return bundle
def obj_create(self, bundle, request=None, **kwargs):
def obj_create(self, bundle, **kwargs):
bundle.data['tags_list'] = bundle.data.get('tags')
bundle.data['tags'] = ''
if 'blog_post' in bundle.data:
bundle = self._clean_publish_date(bundle)
return super(PrivateSniptResource, self).obj_create(bundle, request,
user=request.user, **kwargs)
return super(PrivateSniptResource, self).obj_create(bundle,
user=bundle.request.user, **kwargs)
def obj_update(self, bundle, request=None, **kwargs):
bundle.data['user'] = request.user
def obj_update(self, bundle, **kwargs):
bundle.data['user'] = bundle.request.user
if type(bundle.data['tags']) in (str, unicode):
bundle.data['tags_list'] = bundle.data['tags']
@@ -280,8 +280,8 @@ def obj_update(self, bundle, request=None, **kwargs):
if 'blog_post' in bundle.data:
bundle = self._clean_publish_date(bundle)
return super(PrivateSniptResource, self).obj_update(bundle, request,
user=request.user, **kwargs)
return super(PrivateSniptResource, self).obj_update(bundle,
user=bundle.request.user, **kwargs)
def _clean_publish_date(self, bundle):
if bundle.data['blog_post'] and 'publish_date' not in bundle.data:
@@ -354,11 +354,11 @@ def dehydrate(self, bundle):
bundle.obj.snipt.pk)
return bundle
def obj_create(self, bundle, request=None, **kwargs):
bundle.data['user'] = request.user
def obj_create(self, bundle, **kwargs):
bundle.data['user'] = bundle.request.user
bundle.data['snipt'] = Snipt.objects.get(pk=bundle.data['snipt'])
return super(PrivateFavoriteResource, self).obj_create(bundle, request,
user=request.user, **kwargs)
return super(PrivateFavoriteResource, self).obj_create(bundle,
user=bundle.request.user, **kwargs)
def apply_authorization_limits(self, request, object_list):
return object_list.filter(user=request.user)
@@ -13,6 +13,6 @@ class SniptIndex(indexes.SearchIndex, indexes.Indexable):
def get_model(self):
return Snipt
def index_queryset(self):
def index_queryset(self, **kwargs):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(created__lte=datetime.datetime.now())
@@ -382,8 +382,8 @@ <h3><span>Keyboard shortcuts</span></h3>
{% block js %}
window.user = '{{ request.user.username }}';
window.user_id = {{ request.user.id }};
window.user_profile_id = {{ request.user.profile.id }};
window.user_id = {% firstof request.user.id 'null' %};
window.user_profile_id = {% firstof request.user.profile.id 'null' %};
{% if public %}
window.pub = {{ public|lower }};

0 comments on commit fb0142f

Please sign in to comment.