Anonymous users will see a warning on sending an email. Also removing FeedIcon model (having switched to the mongo MFeedIcon model).

This commit is contained in:
Samuel Clay 2011-05-09 10:30:07 -04:00
parent 1eb844fde6
commit 7b9df8dadc
6 changed files with 117 additions and 33 deletions

View file

@ -1001,7 +1001,7 @@ def send_story_email(request):
headers={'Reply-To': '%s <%s>' % (from_name, from_email)})
msg.attach_alternative(html, "text/html")
msg.send()
logging.user(request.user, '~BMSending story email: ~SB%s~SN~BM/~SB%s' %
logging.user(request.user, '~BMSharing story by email: ~FY~SB%s~SN~BM~FY/~SB%s' %
(story['story_title'][:50], feed.feed_title[:50]))
return {'code': code, 'message': message}

View file

@ -4,7 +4,11 @@ import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from apps.rss_feeds.models import Feed, FeedIcon
from apps.rss_feeds.models import Feed
try:
from apps.rss_feeds.models import FeedIcon
except ImportError:
pass
class Migration(DataMigration):

View file

@ -0,0 +1,91 @@
# 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):
# Deleting model 'FeedIcon'
db.delete_table('rss_feeds_feedicon')
def backwards(self, orm):
# Adding model 'FeedIcon'
db.create_table('rss_feeds_feedicon', (
('feed', self.gf('utils.fields.AutoOneToOneField')(related_name='icon', unique=True, primary_key=True, to=orm['rss_feeds.Feed'])),
('color', self.gf('django.db.models.fields.CharField')(max_length=6, null=True, blank=True)),
('icon_url', self.gf('django.db.models.fields.CharField')(max_length=2000, null=True, blank=True)),
('not_found', self.gf('django.db.models.fields.BooleanField')(default=False)),
('data', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
))
db.send_create_signal('rss_feeds', ['FeedIcon'])
models = {
'rss_feeds.duplicatefeed': {
'Meta': {'object_name': 'DuplicateFeed'},
'duplicate_address': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'duplicate_feed_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'feed': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'duplicate_addresses'", 'to': "orm['rss_feeds.Feed']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'rss_feeds.feed': {
'Meta': {'ordering': "['feed_title']", 'object_name': 'Feed', 'db_table': "'feeds'"},
'active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
'active_subscribers': ('django.db.models.fields.IntegerField', [], {'default': '-1', 'db_index': 'True'}),
'average_stories_per_month': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'creation': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'days_to_trim': ('django.db.models.fields.IntegerField', [], {'default': '90'}),
'etag': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'exception_code': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'favicon_color': ('django.db.models.fields.CharField', [], {'max_length': '6', 'null': 'True', 'blank': 'True'}),
'favicon_not_found': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'feed_address': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '255'}),
'feed_link': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '1000', 'null': 'True', 'blank': 'True'}),
'feed_title': ('django.db.models.fields.CharField', [], {'default': "'[Untitled]'", 'max_length': '255', 'null': 'True', 'blank': 'True'}),
'fetched_once': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'has_feed_exception': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
'has_page_exception': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_load_time': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'last_modified': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'last_update': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}),
'min_to_decay': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'next_scheduled_update': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}),
'num_subscribers': ('django.db.models.fields.IntegerField', [], {'default': '-1'}),
'premium_subscribers': ('django.db.models.fields.IntegerField', [], {'default': '-1'}),
'queued_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}),
'stories_last_month': ('django.db.models.fields.IntegerField', [], {'default': '0'})
},
'rss_feeds.feeddata': {
'Meta': {'object_name': 'FeedData'},
'feed': ('utils.fields.AutoOneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': "orm['rss_feeds.Feed']"}),
'feed_classifier_counts': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'feed_tagline': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'popular_authors': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'}),
'popular_tags': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
'story_count_history': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'})
},
'rss_feeds.feedloadtime': {
'Meta': {'object_name': 'FeedLoadtime'},
'date_accessed': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'feed': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['rss_feeds.Feed']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'loadtime': ('django.db.models.fields.FloatField', [], {})
},
'rss_feeds.feedupdatehistory': {
'Meta': {'object_name': 'FeedUpdateHistory'},
'average_per_feed': ('django.db.models.fields.DecimalField', [], {'max_digits': '4', 'decimal_places': '1'}),
'fetch_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'number_of_feeds': ('django.db.models.fields.IntegerField', [], {}),
'seconds_taken': ('django.db.models.fields.IntegerField', [], {})
}
}
complete_apps = ['rss_feeds']

View file

@ -910,23 +910,6 @@ class FeedData(models.Model):
if hasattr(self, 'id') and self.id: self.delete()
class FeedIcon(models.Model):
feed = AutoOneToOneField(Feed, primary_key=True, related_name='icon')
color = models.CharField(max_length=6, blank=True, null=True)
data = models.TextField(blank=True, null=True)
icon_url = models.CharField(max_length=2000, blank=True, null=True)
not_found = models.BooleanField(default=False)
def save(self, *args, **kwargs):
if self.icon_url:
self.icon_url = unicode(self.icon_url)
try:
super(FeedIcon, self).save(*args, **kwargs)
except (IntegrityError, OperationError):
# print "Error on Icon: %s" % e
if hasattr(self, 'id'): self.delete()
class MFeedIcon(mongo.Document):
feed_id = mongo.IntField(primary_key=True)
color = mongo.StringField(max_length=6)

View file

@ -788,11 +788,11 @@ NEWSBLUR.AssetModel.Reader.prototype = {
}
},
send_story_email: function(data, callback, error_callback) {
send_story_email: function(data, callback) {
if (NEWSBLUR.Globals.is_authenticated) {
this.make_request('/reader/send_story_email', data, callback, error_callback);
this.make_request('/reader/send_story_email', data, callback);
} else {
error_callback('You must be logged in to send a story over email. Just log in or create an account.');
callback({'code': -1, 'message': 'You must be logged in to send a story over email.'});
}
},

View file

@ -19,6 +19,10 @@ NEWSBLUR.ReaderSendEmail.prototype = _.extend({}, NEWSBLUR.Modal.prototype, {
this.make_modal();
this.open_modal();
if (!NEWSBLUR.Globals.is_authenticated) {
this.save_callback({'code': -1, 'message': 'You must be logged in to send a story over email.'});
}
this.$modal.bind('click', $.rescope(this.handle_click, this));
},
@ -77,7 +81,6 @@ NEWSBLUR.ReaderSendEmail.prototype = _.extend({}, NEWSBLUR.Modal.prototype, {
},
save: function(e) {
var self = this;
var from_name = $('input[name=from_name]', this.$modal).val();
var from_email = $('input[name=from_email]', this.$modal).val();
var to = $('input[name=to]', this.$modal).val();
@ -97,16 +100,19 @@ NEWSBLUR.ReaderSendEmail.prototype = _.extend({}, NEWSBLUR.Modal.prototype, {
from_email : from_email,
to : to,
comments : comments
}, _.bind(function(data) {
if (!data || data.code < 0) {
$('.NB-error', this.$modal).html(data.message).fadeIn(500);
$('.NB-modal-loading', this.$modal).removeClass('NB-active');
$save.removeClass('NB-disabled').val('Send this story');
} else {
$save.val('Sent!');
this.close();
}
}, this));
}, _.bind(this.save_callback, this));
},
save_callback: function(data) {
var $save = $('input[type=submit]', this.$modal);
if (!data || data.code < 0) {
$('.NB-error', this.$modal).html(data.message).fadeIn(500);
$('.NB-modal-loading', this.$modal).removeClass('NB-active');
$save.removeClass('NB-disabled').val('Send this story');
} else {
$save.val('Sent!');
this.close();
}
},
// ===========