This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ella.core.models import * | |
article_cat = Category.objects.get(slug='articles') | |
Category.objects.create(slug='best-of', title='Best Of', tree_path='articles/best-of', tree_parent=article_cat, site_id=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_staff_user(username, password, first_name, last_name): | |
from django.contrib.auth.models import User | |
u = User.objects.create( | |
username=username, | |
first_name=first_name, | |
last_name=last_name, | |
is_staff=True, | |
is_superuser=True | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat = Category.objects.get(tree_path='news/best-of') | |
for a in Article.objects.filter(pk__in=[25, 12, 54, 147, 19, 152, 175, 406, 1904, 45, 1299, 2123, 2675]): | |
Listing.objects.create( | |
publishable=a, | |
category=cat, | |
publish_from=a.publish_from, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From prod tested | |
best_of_category = ella.core.models.Category.objects.get(tree_path='news/best-of') | |
for a in vines.Articles.objects.all(): | |
... run your migration code ... | |
if a.evergreen_order > 0: | |
Listing.objects.create( | |
publishable=a, | |
category=best_of_category, | |
publish_from=a.publish_from, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scout.topics.models import Topic | |
from scout.topics.top_posters import TopPosterLogger, log_new_comment | |
for t in Topic.objects.all(): | |
for c in t.comments.all(): | |
if c.category is not None: | |
TopPosterLogger.incr_new_comment( | |
t.category_id, | |
c.user_id | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def log_new_comment(sender, comment, request, **kwargs): | |
" Update the appropriate TopPoster data after a new Comment is created. " | |
print 'comment', comment | |
if hasattr(comment.content_object, 'category'): | |
print 'logging.' | |
TopPosterLogger.incr_new_comment(comment.content_object.category.id, comment.user.id) | |
comment_was_posted.connect(log_new_comment) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- query_params = '?p=' | |
+ query_params = '?' | |
if 'request' in context: | |
get = context['request'].GET | |
- if 'using' in get: | |
- query_params = '?%s&p=' % urlencode({'using': get['using']}) | |
+ query_params += '&'.join(['%s=%s' % (k,v) for k, v in get.items() if k != 'p']) | |
+ query_params += '&p=' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This was executed on production to find all articles whos' Authors | |
# had been deleted | |
[a.id for a in Article.objects.filter(authors=None)] | |
[35, | |
46, | |
48, | |
50, | |
53, | |
56, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.template.defaultfilters import slugify | |
from ella.core.models import Category | |
def create_category(title, parent): | |
Category.objects.create( | |
title=title, | |
slug=slugify(title), | |
tree_parent=parent, | |
site_id=1 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User, Group, Permission | |
from django.contrib.contenttypes.models import ContentType | |
from ella.articles.models import Article | |
from ella.core.models import Listing, Publishable | |
from ella.photos.models import Photo, FormatedPhoto | |
from ella_galleries.models import Gallery, GalleryItem | |
from scout.podcasts.models import Podcast |