mirror of
https://github.com/fergalmoran/dss.git
synced 2026-02-05 15:44:20 +00:00
Fixed wrong user on follow activity
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
.gitignore~
|
||||
.coverage
|
||||
tags
|
||||
.tags
|
||||
.tags_sorted_by_file
|
||||
|
||||
@@ -12,7 +12,7 @@ class NotificationResource(BackboneCompatibleResource):
|
||||
authentication = SessionAuthentication()
|
||||
authorization = DjangoAuthorization()
|
||||
always_return_data = True
|
||||
excludes = ['accepted_date', 'id']
|
||||
excludes = ['accepted_date']
|
||||
|
||||
def authorized_read_list(self, object_list, bundle):
|
||||
return object_list.filter(to_user=bundle.request.user)
|
||||
|
||||
@@ -7,14 +7,22 @@ class Command(NoArgsCommand):
|
||||
help = "Drop and re-create the database"
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
self.pgsql_handle_noargs(options)
|
||||
if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql_psycopg2':
|
||||
self.pgsql_handle_noargs(**options)
|
||||
else:
|
||||
self.mysql_handle_noargs(**options)
|
||||
|
||||
def pgsql_handle_noargs(self, **options):
|
||||
import psycopg2
|
||||
db = psycopg2.connect("dbname=%s user=%s password=%s" % (settings.DATABASES['default']['NAME'], settings.DATABASES['default']['USER'], settings.DATABASES['default']['PASSWORD']))
|
||||
|
||||
db = psycopg2.connect(database='postgres', #settings.DATABASES['default']['NAME'],
|
||||
host=settings.DATABASES['default']['HOST'],
|
||||
user=settings.DATABASES['default']['USER'],
|
||||
password=settings.DATABASES['default']['PASSWORD'])
|
||||
|
||||
cur = db.cursor()
|
||||
cur.execute("drop database %s; create database %s;" % settings.DATABASES['default']['NAME'], settings.DATABASES['default']['NAME'])
|
||||
cur.execute("drop database %s; create database %s;" % (
|
||||
settings.DATABASES['default']['NAME'], settings.DATABASES['default']['NAME']))
|
||||
|
||||
print "Dropped"
|
||||
|
||||
@@ -31,6 +39,6 @@ class Command(NoArgsCommand):
|
||||
cursor = db.cursor()
|
||||
print "Dropping database %s" % settings.DATABASES['default']['NAME']
|
||||
cursor.execute("drop database %s; create database %s;" % (
|
||||
settings.DATABASES['default']['NAME'], settings.DATABASES['default']['NAME']))
|
||||
settings.DATABASES['default']['NAME'], settings.DATABASES['default']['NAME']))
|
||||
print "Dropped"
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ ACTIVITYTYPES = (
|
||||
('f', 'favourited'),
|
||||
)
|
||||
|
||||
|
||||
class ActivityThread(threading.Thread):
|
||||
def __init__(self, instance, **kwargs):
|
||||
self.instance = instance
|
||||
@@ -35,7 +36,9 @@ class Activity(_BaseModel):
|
||||
notification = Notification()
|
||||
notification.from_user = self.user
|
||||
notification.to_user = self.get_target_user()
|
||||
notification.notification_text = "%s %s %s" % (self.user or "Anonymous", self.get_verb_past(), self.get_object_name())
|
||||
notification.notification_text = "%s %s %s" % (
|
||||
self.user.get_nice_name() or "Anonymous", self.get_verb_past(), self.get_object_name_for_notification())
|
||||
|
||||
notification.notification_url = self.get_object_url()
|
||||
notification.verb = self.get_verb_past()
|
||||
notification.target = self.get_object_name()
|
||||
@@ -63,6 +66,9 @@ class Activity(_BaseModel):
|
||||
def get_object_singular(self):
|
||||
pass
|
||||
|
||||
def get_object_name_for_notification(self):
|
||||
return self.get_object_name()
|
||||
|
||||
|
||||
class ActivityFollow(Activity):
|
||||
to_user = models.ForeignKey('spa.UserProfile', related_name='follower_activity')
|
||||
@@ -71,7 +77,7 @@ class ActivityFollow(Activity):
|
||||
return self.to_user
|
||||
|
||||
def get_object_name(self):
|
||||
return self.user.get_nice_name()
|
||||
return self.to_user.get_nice_name()
|
||||
|
||||
def get_object_url(self):
|
||||
return self.user.get_profile_url()
|
||||
@@ -82,6 +88,9 @@ class ActivityFollow(Activity):
|
||||
def get_verb_past(self):
|
||||
return "followed"
|
||||
|
||||
def get_object_name_for_notification(self):
|
||||
return "You"
|
||||
|
||||
|
||||
class ActivityFavourite(Activity):
|
||||
mix = models.ForeignKey('spa.Mix', related_name='favourites')
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
// Generated by CoffeeScript 1.6.2
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
|
||||
define(['vent', 'socket.io'], function(vent, SocketIO) {
|
||||
var RealtimeController;
|
||||
|
||||
RealtimeController = (function() {
|
||||
|
||||
function RealtimeController() {}
|
||||
|
||||
RealtimeController.prototype.startSocketIO = function() {
|
||||
var _this = this;
|
||||
|
||||
console.log("RealtimeController: Socket IO starting");
|
||||
this.socket = SocketIO.connect(com.podnoms.settings.REALTIME_HOST);
|
||||
this.socket.on("hello", function(data) {
|
||||
return console.log("RealtimeController: Connected " + data['message']);
|
||||
});
|
||||
"@socket.on \"activity\", (data) =>\n console.log(\"RealtimeController: activity \" + data['message'])\n vent.trigger(\"model:activity:new\", data['message'])";
|
||||
|
||||
return this.socket.on("notification", function(data) {
|
||||
console.log("RealtimeController: notification " + data['message']);
|
||||
return vent.trigger("model:notification:new", data['message']);
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Generated by CoffeeScript 1.6.2
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
define(['backbone', 'vent', 'models/notifications/notificationItem', 'app.lib/backbone.dss.model.collection'], function(Backbone, vent, NotificationItem, DssCollection) {
|
||||
var NotificationCollection, _ref;
|
||||
|
||||
var NotificationCollection;
|
||||
NotificationCollection = (function(_super) {
|
||||
|
||||
__extends(NotificationCollection, _super);
|
||||
|
||||
function NotificationCollection() {
|
||||
_ref = NotificationCollection.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
return NotificationCollection.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
NotificationCollection.prototype.model = NotificationItem;
|
||||
@@ -22,10 +21,8 @@
|
||||
|
||||
NotificationCollection.prototype.initialize = function() {
|
||||
var _this = this;
|
||||
|
||||
return this.listenTo(vent, "model:notification:new", function(url) {
|
||||
var item;
|
||||
|
||||
console.log("NotificationCollection: notification:new");
|
||||
item = new NotificationItem();
|
||||
return item.fetch({
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Generated by CoffeeScript 1.6.2
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
define(['marionette', 'models/activity/activityCollection', 'views/activity/activityItemView', 'text!/tpl/ActivityListView'], function(Marionette, ActivityCollection, ActivityItemView, Template) {
|
||||
var ActivityListView, _ref;
|
||||
|
||||
var ActivityListView;
|
||||
ActivityListView = (function(_super) {
|
||||
|
||||
__extends(ActivityListView, _super);
|
||||
|
||||
function ActivityListView() {
|
||||
_ref = ActivityListView.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
return ActivityListView.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
ActivityListView.prototype.template = _.template(Template);
|
||||
@@ -31,7 +30,6 @@
|
||||
|
||||
ActivityListView.prototype.appendHtml = function(collectionView, itemView, index) {
|
||||
var children, childrenContainer;
|
||||
|
||||
childrenContainer = (collectionView.itemViewContainer ? collectionView.$(collectionView.itemViewContainer) : collectionView.$el);
|
||||
children = childrenContainer.children();
|
||||
if (children.size() <= index) {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// Generated by CoffeeScript 1.6.2
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
define(['marionette', 'underscore', 'vent', 'utils', 'models/notifications/notificationCollection', 'views/notifications/notificationsItemView', 'text!/tpl/NotificationsListView'], function(Marionette, _, vent, utils, NotificationCollection, NotificationsItemView, Template) {
|
||||
var NotificationsListView, _ref;
|
||||
|
||||
var NotificationsListView;
|
||||
NotificationsListView = (function(_super) {
|
||||
|
||||
__extends(NotificationsListView, _super);
|
||||
|
||||
function NotificationsListView() {
|
||||
this.initialize = __bind(this.initialize, this); _ref = NotificationsListView.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
this.initialize = __bind(this.initialize, this);
|
||||
return NotificationsListView.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
NotificationsListView.prototype.template = _.template(Template);
|
||||
@@ -36,7 +36,6 @@
|
||||
|
||||
NotificationsListView.prototype.initialize = function() {
|
||||
var _this = this;
|
||||
|
||||
this.collection = new NotificationCollection;
|
||||
return this.collection.fetch({
|
||||
success: function() {
|
||||
@@ -69,7 +68,6 @@
|
||||
|
||||
NotificationsListView.prototype.showNotifications = function() {
|
||||
var _this = this;
|
||||
|
||||
return $.ajax({
|
||||
url: '/ajax/mark_read/',
|
||||
type: 'post',
|
||||
|
||||
Reference in New Issue
Block a user