diff --git a/spa/api/v1/UserResource.py b/spa/api/v1/UserResource.py index 2dcda80..6e5734a 100755 --- a/spa/api/v1/UserResource.py +++ b/spa/api/v1/UserResource.py @@ -1,4 +1,3 @@ -from django.contrib.auth.models import User from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from django.db.models import Count, Q from tastypie import fields @@ -75,14 +74,15 @@ class UserResource(BackboneCompatibleResource): def _patch_resource(self, bundle): #Handle the patched items from backbone - if bundle.data['following']: - bundle.obj.add_follower(bundle.request.user.get_profile()) - activity = ActivityFollow() - activity.user = bundle.request.user.get_profile() - activity.to_user = bundle.obj - activity.save() - else: - bundle.obj.remove_follower(bundle.request.user.get_profile()) + if 'following' in bundle.data: + if bundle.data['following']: + bundle.obj.add_follower(bundle.request.user.get_profile()) + activity = ActivityFollow() + activity.user = bundle.request.user.get_profile() + activity.to_user = bundle.obj + activity.save() + else: + bundle.obj.remove_follower(bundle.request.user.get_profile()) def obj_update(self, bundle, skip_errors=False, **kwargs): """ @@ -95,16 +95,28 @@ class UserResource(BackboneCompatibleResource): if 'activity_sharing_favourites' in kwargs: del kwargs['activity_sharing_favourites'] if 'activity_sharing_comments' in kwargs: del kwargs['activity_sharing_comments'] - self._patch_resource(bundle) + #need to figure out why this is excepting, granted I shouldn't be + #trying to update followers in here but still though. + try: + self._patch_resource(bundle) + except: + pass + return super(UserResource, self).obj_update(bundle, skip_errors, **kwargs) + def dehydrate_description(self, bundle): + return bundle.obj.get_profile_description() + def dehydrate(self, bundle): del bundle.data['activity_sharing'] del bundle.data['activity_sharing_networks'] bundle.data['display_name'] = bundle.obj.get_nice_name() bundle.data['avatar_image'] = bundle.obj.get_avatar_image() if bundle.obj.user.id == bundle.request.user.id: + bundle.data['email'] = bundle.obj.email + bundle.data['first_name'] = bundle.obj.first_name + bundle.data['last_name'] = bundle.obj.last_name bundle.data['activity_sharing_likes'] = \ self._hydrateBitmapOption(bundle.obj.activity_sharing, UserProfile.ACTIVITY_SHARE_LIKES) bundle.data['activity_sharing_favourites'] = \ diff --git a/spa/models/userprofile.py b/spa/models/userprofile.py index b15205c..a46ea29 100755 --- a/spa/models/userprofile.py +++ b/spa/models/userprofile.py @@ -117,7 +117,8 @@ class UserProfile(_BaseModel): self.logger.error("Backend: %s" % settings.EMAIL_BACKEND) def remove_follower(self, user): - self.followers.remove(user) + if user in self.followers: + self.followers.remove(user) def is_follower(self, user): try: @@ -174,13 +175,28 @@ class UserProfile(_BaseModel): except Exception, ex: pass elif avatar_type == 'custom' or avatar_type: - return self.avatar_image.name + return urlparse.urljoin(settings.MEDIA_URL, self.avatar_image.name) return UserProfile.get_default_avatar_image() def get_profile_url(self): return '/user/%s' % (self.slug) + def get_profile_description(self): + try: + if not self.description: + social_account = SocialAccount.objects.filter(user=self.user)[0] + if social_account is not None: + provider = social_account.get_provider_account() + if 'bio' in provider.account.extra_data: + return provider.account.extra_data['bio'] + else: + return self.description + except Exception, ex: + pass + + return "Too lazy to update my description" + @classmethod def get_default_avatar_image(cls): return urlparse.urljoin(settings.STATIC_URL, "img/default-avatar-32.png") diff --git a/static/css/deepsouthsounds.css b/static/css/deepsouthsounds.css index 0cdcb94..33dcc98 100755 --- a/static/css/deepsouthsounds.css +++ b/static/css/deepsouthsounds.css @@ -89,7 +89,10 @@ ul.comment-listing .comment-entry { width: 32px; height: 32px; } - +.image-user-profile{ + width: 320px; + height: 200px; +} .social_login_providers { width: 100%; float: left; diff --git a/static/js/app/lib/controller.js b/static/js/app/lib/controller.js index 057be06..fec518b 100755 --- a/static/js/app/lib/controller.js +++ b/static/js/app/lib/controller.js @@ -1,16 +1,17 @@ -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.6.2 (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(['app', 'marionette', 'vent', 'views/chat/chatView', 'models/mix/mixItem', 'views/mix/mixListLayout', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView', 'models/user/userItem', 'views/user/userListView', 'views/user/userEditView'], function(App, Marionette, vent, ChatView, MixItem, MixListLayout, MixListView, MixDetailView, MixEditView, UserItem, UserListView, UserEditView) { - var DssController; - DssController = (function(_super) { + var DssController, _ref; + DssController = (function(_super) { __extends(DssController, _super); function DssController() { - return DssController.__super__.constructor.apply(this, arguments); + _ref = DssController.__super__.constructor.apply(this, arguments); + return _ref; } DssController.prototype.home = function() { @@ -21,6 +22,7 @@ DssController.prototype._showMixList = function() { var app; + app = require('app'); app.contentRegion.show(new MixListLayout()); return true; @@ -36,6 +38,7 @@ DssController.prototype.showMix = function(slug) { var app, mix; + console.log("Controller: showMix"); app = require('app'); mix = new MixItem({ @@ -54,6 +57,7 @@ DssController.prototype.uploadMix = function() { var app, mix; + console.log("Controller: mixUpload"); app = require('app'); mix = new MixItem({ @@ -70,6 +74,7 @@ DssController.prototype.editMix = function(slug) { var app, mix; + console.log("Controller: mixEdit"); app = require('app'); mix = new MixItem({ @@ -87,6 +92,7 @@ DssController.prototype.showChat = function() { var app; + console.log("Controller: showChat"); app = require('app'); return app.contentRegion.show(new ChatView()); @@ -94,6 +100,7 @@ DssController.prototype.showUserList = function(type) { var app; + console.log("Controller: showUserList"); app = require('app'); return app.contentRegion.show(new UserListView()); @@ -150,6 +157,7 @@ DssController.prototype.editUser = function() { var app, user; + console.log("Controller: editUser"); app = require('app'); user = new UserItem({ diff --git a/static/js/app/lib/router.js b/static/js/app/lib/router.js index 00017b4..e33b7fc 100755 --- a/static/js/app/lib/router.js +++ b/static/js/app/lib/router.js @@ -1,16 +1,17 @@ -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.6.2 (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', 'vent', 'app.lib/controller'], function(Marionette, vent, Controller) { - var DssRouter; - return DssRouter = (function(_super) { + var DssRouter, _ref; + return DssRouter = (function(_super) { __extends(DssRouter, _super); function DssRouter() { - return DssRouter.__super__.constructor.apply(this, arguments); + _ref = DssRouter.__super__.constructor.apply(this, arguments); + return _ref; } DssRouter.prototype.controller = new Controller; diff --git a/static/js/app/views/mix/mixItemView.coffee b/static/js/app/views/mix/mixItemView.coffee index e876e01..8840d66 100755 --- a/static/js/app/views/mix/mixItemView.coffee +++ b/static/js/app/views/mix/mixItemView.coffee @@ -48,7 +48,7 @@ define ['moment', 'app', 'vent', 'marionette', 'utils', 'models/comment/commentC renderGenres: => el = @el $.each @model.get("genre-list"), (data) -> - $("#genre-list", el).append '' + @text + '' + $("#genre-list", el).append '' + @text + '' true true diff --git a/static/js/app/views/mix/mixItemView.js b/static/js/app/views/mix/mixItemView.js index 690cb30..35ff84a 100755 --- a/static/js/app/views/mix/mixItemView.js +++ b/static/js/app/views/mix/mixItemView.js @@ -1,26 +1,22 @@ -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.6.2 (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(['moment', 'app', 'vent', 'marionette', 'utils', 'models/comment/commentCollection', 'views/comment/commentListView', 'text!/tpl/MixListItemView'], function(moment, App, vent, Marionette, utils, CommentsCollection, CommentsListView, Template) { - var MixItemView; - MixItemView = (function(_super) { + var MixItemView, _ref; + MixItemView = (function(_super) { __extends(MixItemView, _super); function MixItemView() { this.doStart = __bind(this.doStart, this); - this.renderComments = __bind(this.renderComments, this); - this.renderGenres = __bind(this.renderGenres, this); - this.onRender = __bind(this.onRender, this); - - this.initialize = __bind(this.initialize, this); - return MixItemView.__super__.constructor.apply(this, arguments); + this.initialize = __bind(this.initialize, this); _ref = MixItemView.__super__.constructor.apply(this, arguments); + return _ref; } MixItemView.prototype.template = _.template(Template); @@ -54,6 +50,7 @@ MixItemView.prototype.onRender = function() { var id, totalDuration, totalDurationText; + id = this.model.get('id'); if (this.model.get('duration')) { totalDuration = moment.duration(this.model.get('duration'), "seconds"); @@ -73,9 +70,10 @@ MixItemView.prototype.renderGenres = function() { var el; + el = this.el; $.each(this.model.get("genre-list"), function(data) { - $("#genre-list", el).append('' + this.text + ''); + $("#genre-list", el).append('' + this.text + ''); return true; }); return true; @@ -83,6 +81,7 @@ MixItemView.prototype.renderComments = function() { var comments; + comments = new CommentsCollection(); comments.url = this.model.get("resource_uri") + "comments/"; comments.mix_id = this.model.id; @@ -90,6 +89,7 @@ comments.fetch({ success: function(data) { var content; + console.log(data); content = new CommentsListView({ collection: comments @@ -139,6 +139,7 @@ MixItemView.prototype.mixFavourite = function() { var app; + console.log("MixItemView: favouriteMix"); app = require('app'); vent.trigger("mix:favourite", this.model); @@ -153,6 +154,7 @@ MixItemView.prototype.mixShare = function(e) { var mode; + console.log("MixItemView: shareMix"); mode = $(e.currentTarget).data("mode"); console.log("MixItemView: " + mode); diff --git a/static/js/app/views/mix/mixListView.js b/static/js/app/views/mix/mixListView.js index bd40547..0555fee 100755 --- a/static/js/app/views/mix/mixListView.js +++ b/static/js/app/views/mix/mixListView.js @@ -1,17 +1,19 @@ -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.6.2 (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', 'vent', 'models/mix/mixCollection', 'views/mix/mixItemView', 'text!/tpl/MixListView'], function(Marionette, vent, MixCollection, MixItemView, Template) { - var MixListView; + var MixListView, _ref; + MixListView = (function(_super) { var currentMix; __extends(MixListView, _super); function MixListView() { - return MixListView.__super__.constructor.apply(this, arguments); + _ref = MixListView.__super__.constructor.apply(this, arguments); + return _ref; } MixListView.prototype.template = _.template(Template); @@ -33,6 +35,7 @@ MixListView.prototype.mixPlay = function(model) { var v; + if (currentMix !== -1) { v = this.children.findByModelCid(currentMix); v.mixStop(v.model); diff --git a/static/js/app/views/user/userEditView.coffee b/static/js/app/views/user/userEditView.coffee index 03ef9d8..0ac516d 100755 --- a/static/js/app/views/user/userEditView.coffee +++ b/static/js/app/views/user/userEditView.coffee @@ -8,7 +8,7 @@ define ['app', 'toastr', 'app.lib/editableView', 'moment', 'libs/backbone/backbo onRender: -> console.log("MixEditView: onRender") - avatarType = @model.get('profile').avatar_type + avatarType = @model.get('avatar_type') $('#avatar_' + avatarType, @el).attr('checked', true); if avatarType is "custom" $("#div_avatar_image_upload", @el).show() @@ -32,7 +32,7 @@ define ['app', 'toastr', 'app.lib/editableView', 'moment', 'libs/backbone/backbo ref = this @_saveChanges success: -> - if ref.model.get("profile").avatar_type is "custom" + if ref.model.get('avatar_type') is "custom" $.ajaxFileUpload url: "/ajax/upload_avatar_image/" secureuri: false diff --git a/static/js/app/views/user/userEditView.js b/static/js/app/views/user/userEditView.js index 0e85f7c..8a53230 100755 --- a/static/js/app/views/user/userEditView.js +++ b/static/js/app/views/user/userEditView.js @@ -1,16 +1,17 @@ -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.6.2 (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(['app', 'toastr', 'app.lib/editableView', 'moment', 'libs/backbone/backbone.syphon', 'text!/tpl/UserEditView'], function(App, toastr, EditableView, moment, Syphon, Template) { - var UserEditView; - UserEditView = (function(_super) { + var UserEditView, _ref; + UserEditView = (function(_super) { __extends(UserEditView, _super); function UserEditView() { - return UserEditView.__super__.constructor.apply(this, arguments); + _ref = UserEditView.__super__.constructor.apply(this, arguments); + return _ref; } UserEditView.prototype.template = _.template(Template); @@ -22,8 +23,9 @@ UserEditView.prototype.onRender = function() { var avatarType; + console.log("MixEditView: onRender"); - avatarType = this.model.get('profile').avatar_type; + avatarType = this.model.get('avatar_type'); $('#avatar_' + avatarType, this.el).attr('checked', true); if (avatarType === "custom") { $("#div_avatar_image_upload", this.el).show(); @@ -38,6 +40,7 @@ UserEditView.prototype.selectAvatar = function(evt) { var type; + type = $(evt.currentTarget).val(); this.model.set("avatar_type", type); if (type === "custom") { @@ -52,12 +55,13 @@ UserEditView.prototype.saveChanges = function() { var data, ref; + data = Backbone.Syphon.serialize(this); this.model.set(data); ref = this; this._saveChanges({ success: function() { - if (ref.model.get("profile").avatar_type === "custom") { + if (ref.model.get('avatar_type') === "custom") { $.ajaxFileUpload({ url: "/ajax/upload_avatar_image/", secureuri: false, diff --git a/static/js/app/views/user/userItemView.coffee b/static/js/app/views/user/userItemView.coffee index f86f72f..5ca90cf 100755 --- a/static/js/app/views/user/userItemView.coffee +++ b/static/js/app/views/user/userItemView.coffee @@ -2,7 +2,8 @@ define ['app', 'moment', 'marionette', 'vent', 'text!/tpl/UserListItemView'], (App, moment, Marionette, vent, Template)-> class UserItemView extends Marionette.ItemView template: _.template(Template) - tagName: "tr" + tagName: "div" + className: "row-fluid" events: "click #follow-button": "followUser" diff --git a/static/js/app/views/user/userItemView.js b/static/js/app/views/user/userItemView.js index f4743d1..61cd0fd 100755 --- a/static/js/app/views/user/userItemView.js +++ b/static/js/app/views/user/userItemView.js @@ -17,7 +17,9 @@ UserItemView.prototype.template = _.template(Template); - UserItemView.prototype.tagName = "tr"; + UserItemView.prototype.tagName = "div"; + + UserItemView.prototype.className = "row-fluid"; UserItemView.prototype.events = { "click #follow-button": "followUser", diff --git a/static/js/app/views/user/userListView.coffee b/static/js/app/views/user/userListView.coffee index 77c13c6..dbea644 100755 --- a/static/js/app/views/user/userListView.coffee +++ b/static/js/app/views/user/userListView.coffee @@ -11,7 +11,7 @@ define ['jquery', 'marionette', 'models/user/userCollection', 'views/user/userIt searchText: "#search-text" itemView: UserItemView - itemViewContainer: "tbody" + itemViewContainer: "#user-table" initialize: => console.log "UserListView: initialize" @collection = new UserCollection() diff --git a/static/js/app/views/user/userListView.js b/static/js/app/views/user/userListView.js index 87531df..6570a4d 100755 --- a/static/js/app/views/user/userListView.js +++ b/static/js/app/views/user/userListView.js @@ -29,7 +29,7 @@ UserListView.prototype.itemView = UserItemView; - UserListView.prototype.itemViewContainer = "tbody"; + UserListView.prototype.itemViewContainer = "#user-table"; UserListView.prototype.initialize = function() { console.log("UserListView: initialize"); diff --git a/templates/views/UserEditView.html b/templates/views/UserEditView.html index 36121c5..79cffe5 100755 --- a/templates/views/UserEditView.html +++ b/templates/views/UserEditView.html @@ -5,23 +5,23 @@
- +
- +
- +
@@ -51,9 +51,9 @@
- - - + + +
@@ -62,7 +62,7 @@
- +
@@ -87,7 +87,7 @@

Tell us a bit about yourself.

- +

@@ -104,16 +104,16 @@ - > + > - > + > - > + > @@ -129,10 +129,10 @@ - > + > - > + > diff --git a/templates/views/UserListItemView.html b/templates/views/UserListItemView.html index 0cc6056..044cdec 100755 --- a/templates/views/UserListItemView.html +++ b/templates/views/UserListItemView.html @@ -1,34 +1,83 @@ - - <%= display_name %> - - - <%= mix_count%> - - - <%= like_count%> - - - <%= favourite_count%> - - - <%= follower_count %> - -<%= following_count %> -<%= humanise(date_joined) %> -<%= humanise(last_login) %> +

+
+
    +
  • + {% if user.is_authenticated %} + + {% else %} + + {% endif %} +
  • +
  • +

    <%= display_name %> +

    +
  • +
+
+
+
+ + + +
+
+

+ <%= description %> +

+
+
+
+
+

- - {% if user.is_authenticated %} - - {% else %} - - {% endif %} - +

+ | Joined: <%= humanise(date_joined) %> + | Last Seen: <%= humanise(last_login) %> +

+ +

+ | <%= mix_count%> Mixes + | <%= favourite_count %> + Favourites + | <%= like_count %> Likes + | <%= follower_count %> Followers + | <%= following_count %> Following +

+
+
+
+ \ No newline at end of file diff --git a/templates/views/UserListView.html b/templates/views/UserListView.html index 0a44aa7..b4fc8f4 100755 --- a/templates/views/UserListView.html +++ b/templates/views/UserListView.html @@ -1,31 +1,15 @@ -
- - - - - - - - - - - - - - - - - - -
-
- -
-
-
-
-
NameUploadsLikesFavouritesFollowersFollowingJoin dateLast seen 
+
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file