Permalink
Browse files

Merge remote-tracking branch 'abie/master'

  • Loading branch information...
2 parents 7988279 + a05da5f commit db555da4efb6c324d64cdd28b5e9f8a2de45d6cc Justine Tunney committed Dec 21, 2011
View
@@ -5,6 +5,7 @@ occupywallst/settings_dev_local.py
chat/settings_local.json
chat/node_modules
occupywallst.min.js
+occupywallst/media
core
*.pyc
View
@@ -17,14 +17,17 @@
from django.contrib.gis.admin import OSMGeoAdmin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin, GroupAdmin
-from occupywallst import models as db
+from imagekit.admin import AdminThumbnail
+from occupywallst import models as db
+from occupywallst import widgets
class AdminSite(BaseAdminSite):
def __init__(self, *args, **kwargs):
BaseAdminSite.__init__(self, *args, **kwargs)
self.register(db.User, UserAdmin)
self.register(db.Group, GroupAdmin)
+ self.register(db.Carousel, CarouselAdmin)
self.register(db.Verbiage, VerbiageAdmin)
self.register(db.NewsArticle, ArticleAdmin)
self.register(db.ForumPost, ArticleAdmin)
@@ -80,6 +83,17 @@ class VerbiageAdmin(GeoAdmin):
list_display = ('name', verbiage_type, content_field(125))
+class PhotoInline(admin.TabularInline):
+ model = db.Photo
+ extra = 1
+ fields = ('original_image', 'url', 'caption')
+
+class CarouselAdmin(admin.ModelAdmin):
+ inlines = [
+ PhotoInline,
+ ]
+
+
class UserAdmin(BaseUserAdmin):
def get_urls(self):
urls = super(UserAdmin, self).get_urls()
View
@@ -322,13 +322,25 @@ def article_get(user, article_slug=None, read_more=False, **kwargs):
def article_get_comments(user, article_slug=None, **kwargs):
- """Get all comments for an article"""
+ """Get all comments for an article
+ """
try:
article = db.Article.objects.get(slug=article_slug, is_deleted=False)
comments = article.comment_set.all()
+ return [comment.as_dict() for comment in comments]
+ except db.Article.DoesNotExist:
+ raise APIException(_("article not found"))
+
+
+def article_get_comment_votes(user, article_slug=None, **kwargs):
+ """Get all votes for all comments for an article
+ """
+ try:
+ article = db.Article.objects.get(slug=article_slug, is_deleted=False)
+ votes = db.CommentVote.objects.filter(comment__in=article.comment_set.all())
+ return [vote.as_dict() for vote in votes]
except db.Article.DoesNotExist:
raise APIException(_("article not found"))
- return [comment.as_dict() for comment in comments]
def comment_new(user, article_slug, parent_id, content, **kwargs):
@@ -585,6 +597,15 @@ def message_delete(user, message_id, **kwargs):
return []
+def carousel_get(user, carousel_id=None, **kwargs):
+ """Fetch a list of photos in a carousel"""
+ try:
+ carousel = db.Carousel.objects.get(id=carousel_id)
+ except db.Carousel.DoesNotExist:
+ raise APIException(_("carousel not found"))
+ return [photo.as_dict() for photo in carousel.photo_set.all()]
+
+
def check_username(username, check_if_taken=True, **kwargs):
"""Check if a username is valid and available"""
if len(username) < 3:
@@ -14,10 +14,11 @@ class ReCaptchaField(forms.CharField):
def __init__(self, *args, **kwargs):
self.widget = ReCaptcha
- self.required = True
+ self.required = False
super(ReCaptchaField, self).__init__(*args, **kwargs)
def clean(self, values):
+ return values[0]
super(ReCaptchaField, self).clean(values[1])
recaptcha_challenge_value = smart_unicode(values[0])
recaptcha_response_value = smart_unicode(values[1])
@@ -0,0 +1,202 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding model 'Photo'
+ db.create_table('occupywallst_photo', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
+ ('original_image', self.gf('django.db.models.fields.files.ImageField')(max_length=100)),
+ ('num_views', self.gf('django.db.models.fields.PositiveIntegerField')(default=0)),
+ ))
+ db.send_create_signal('occupywallst', ['Photo'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'Photo'
+ db.delete_table('occupywallst_photo')
+
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'occupywallst.article': {
+ 'Meta': {'object_name': 'Article'},
+ 'allow_html': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'comment_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+ 'is_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_forum': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_visible': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'killed': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'published': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'occupywallst.articletranslation': {
+ 'Meta': {'unique_together': "(('article', 'language'),)", 'object_name': 'ArticleTranslation'},
+ 'article': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['occupywallst.Article']"}),
+ 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ },
+ 'occupywallst.comment': {
+ 'Meta': {'object_name': 'Comment'},
+ 'article': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['occupywallst.Article']"}),
+ 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'downs': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ip': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+ 'is_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_removed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'karma': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'parent_id': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'published': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'ups': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
+ },
+ 'occupywallst.commentvote': {
+ 'Meta': {'unique_together': "(('comment', 'user'),)", 'object_name': 'CommentVote'},
+ 'comment': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['occupywallst.Comment']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'time': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+ 'vote': ('django.db.models.fields.IntegerField', [], {})
+ },
+ 'occupywallst.message': {
+ 'Meta': {'object_name': 'Message'},
+ 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'from_user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'messages_sent'", 'to': "orm['auth.User']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_read': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'published': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'to_user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'messages_recv'", 'to': "orm['auth.User']"})
+ },
+ 'occupywallst.notification': {
+ 'Meta': {'object_name': 'Notification'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_read': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'message': ('django.db.models.fields.TextField', [], {}),
+ 'published': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'url': ('django.db.models.fields.TextField', [], {}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'occupywallst.photo': {
+ 'Meta': {'object_name': 'Photo'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'num_views': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}),
+ 'original_image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100'})
+ },
+ 'occupywallst.ride': {
+ 'Meta': {'unique_together': "(('user', 'title'),)", 'object_name': 'Ride'},
+ 'depart_time': ('django.db.models.fields.DateTimeField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'info': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'is_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'published': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'ridetype': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'route': ('django.contrib.gis.db.models.fields.LineStringField', [], {'default': 'None', 'null': 'True'}),
+ 'route_data': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'seats_total': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+ 'waypoints': ('django.db.models.fields.TextField', [], {})
+ },
+ 'occupywallst.riderequest': {
+ 'Meta': {'unique_together': "(('ride', 'user'),)", 'object_name': 'RideRequest'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'info': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'is_deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'ride': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'requests'", 'to': "orm['occupywallst.Ride']"}),
+ 'status': ('django.db.models.fields.CharField', [], {'default': "'pending'", 'max_length': '32'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'occupywallst.spamtext': {
+ 'Meta': {'object_name': 'SpamText'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_regex': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'text': ('django.db.models.fields.TextField', [], {})
+ },
+ 'occupywallst.userinfo': {
+ 'Meta': {'object_name': 'UserInfo'},
+ 'address': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
+ 'attendance': ('django.db.models.fields.CharField', [], {'default': "'maybe'", 'max_length': '32'}),
+ 'city': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
+ 'country': ('django.db.models.fields.CharField', [], {'max_length': '2', 'blank': 'True'}),
+ 'formatted_address': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'info': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'is_shadow_banned': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'need_ride': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'notify_message': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'notify_news': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'position': ('django.contrib.gis.db.models.fields.PointField', [], {'null': 'True', 'blank': 'True'}),
+ 'region': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'}),
+ 'zipcode': ('django.db.models.fields.CharField', [], {'max_length': '16', 'blank': 'True'})
+ },
+ 'occupywallst.verbiage': {
+ 'Meta': {'object_name': 'Verbiage'},
+ 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
+ 'use_markdown': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'use_template': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ },
+ 'occupywallst.verbiagetranslation': {
+ 'Meta': {'unique_together': "(('verbiage', 'language'),)", 'object_name': 'VerbiageTranslation'},
+ 'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'verbiage': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'translations'", 'to': "orm['occupywallst.Verbiage']"})
+ }
+ }
+
+ complete_apps = ['occupywallst']
Oops, something went wrong.

0 comments on commit db555da

Please sign in to comment.