Added user list view

This commit is contained in:
Fergal Moran
2013-05-26 12:56:52 +01:00
parent 134280c028
commit 416920a1e9
13 changed files with 108 additions and 33 deletions

View File

@@ -24,7 +24,7 @@ class ActivityResource(BackboneCompatibleResource):
user_image = bundle.obj.user.get_profile().get_small_profile_image()
user_profile = bundle.obj.user.get_profile().get_profile_url()
else:
user_name = "Anonymous user"
user_name = "Anonymous"
user_image = UserProfile.get_default_avatar_image()
user_profile = ""
@@ -45,13 +45,3 @@ class ActivityResource(BackboneCompatibleResource):
except Exception, ee:
self.logger.debug("Exception: Error dehydrating activity, %s" % ee.message)
return None
""""
def alter_list_data_to_serialize(self, request, data):
return [i for i in data['objects'] if i is not None and i.obj.user is not None and i.obj.get_object_name is not None and i.obj.get_object_url is not None]
"""
"""
def dehydrate_date(self, bundle):
return self.humanize_date(bundle.obj.date)
"""

View File

@@ -1,7 +1,7 @@
define ['app', 'marionette',
'models/mix/mixItem', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView',
'models/user/userItem', 'views/user/userEditView'],
(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserEditView)->
'models/user/userItem', 'views/user/userListView', 'views/user/userEditView'],
(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserListView, UserEditView)->
class DssController extends Marionette.Controller
home: ->
console.log "Controller: home"
@@ -49,7 +49,14 @@ define ['app', 'marionette',
)
true
user: (slug) ->
showUserList: (type) ->
console.log("Controller: showUserList")
app = require('app')
app.contentRegion.show(new UserListView())
showUserDetail: (slug) ->
console.log("Controller: showUserDetail")
@showMixList('latest', {user: slug})
editUser: () ->

View File

@@ -3,7 +3,7 @@
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', 'models/mix/mixItem', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView', 'models/user/userItem', 'views/user/userEditView'], function(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserEditView) {
define(['app', 'marionette', 'models/mix/mixItem', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView', 'models/user/userItem', 'views/user/userListView', 'views/user/userEditView'], function(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserListView, UserEditView) {
var DssController;
DssController = (function(_super) {
@@ -81,7 +81,15 @@
return true;
};
DssController.prototype.user = function(slug) {
DssController.prototype.showUserList = function(type) {
var app;
console.log("Controller: showUserList");
app = require('app');
return app.contentRegion.show(new UserListView());
};
DssController.prototype.showUserDetail = function(slug) {
console.log("Controller: showUserDetail");
return this.showMixList('latest', {
user: slug
});

View File

@@ -12,7 +12,8 @@ define ['marionette', 'app.lib/controller'],
"mix/:slug": "showMix"
"mix/edit/:slug": "editMix",
"user/:slug": "user"
"users": "showUserList"
"user/:slug": "showUserDetail"
"me": "editUser"

View File

@@ -23,7 +23,8 @@
"mixes/:type": "showMixList",
"mix/:slug": "showMix",
"mix/edit/:slug": "editMix",
"user/:slug": "user",
"users": "showUserList",
"user/:slug": "showUserDetail",
"me": "editUser"
};

View File

@@ -8,7 +8,7 @@ define ['marionette', 'models/mix/mixCollection', 'views/mix/mixItemView', 'text
itemViewContainer: "#mix-list-container-ul"
initialize: ->
console.log "MixListView: Before render"
console.log "MixListView: initialize"
@collection = new MixCollection()
@collection.fetch(
data: @options

View File

@@ -23,7 +23,7 @@
MixListView.prototype.initialize = function() {
var _this = this;
console.log("MixListView: Before render");
console.log("MixListView: initialize");
this.collection = new MixCollection();
this.collection.fetch({
data: this.options,

View File

@@ -1,5 +1,5 @@
define ['app', 'marionette'],
(App, Marionette)->
define ['app', 'marionette', 'text!/tpl/UserListItemView'],
(App, Marionette, Template)->
class UserItemView extends Marionette.ItemView
itemView: UserItemView
template: _.template(Template)
tagName: "tr"

View File

@@ -3,7 +3,7 @@
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'], function(App, Marionette) {
define(['app', 'marionette', 'text!/tpl/UserListItemView'], function(App, Marionette, Template) {
var UserItemView;
return UserItemView = (function(_super) {
@@ -13,7 +13,9 @@
return UserItemView.__super__.constructor.apply(this, arguments);
}
UserItemView.prototype.itemView = UserItemView;
UserItemView.prototype.template = _.template(Template);
UserItemView.prototype.tagName = "tr";
return UserItemView;

View File

@@ -1,10 +1,21 @@
define ['marionette', 'views/user/userItemView'],
(Marionette, UserItemView) ->
define ['marionette', 'models/user/userCollection', 'views/user/userItemView', 'text!/tpl/UserListView'],
(Marionette, UserCollection, UserItemView, Template) ->
class UserListView extends Marionette.CompositeView
template: "<h1>Hello Sailor</h1"
template: _.template(Template)
tagName: "table"
className: "table table-striped"
itemView: UserItemView
itemViewContainer: "#content"
tagName: "li"
initialize: ->
console.log "UserListView: initialize"
@collection = new UserCollection()
@collection.fetch(
data: @options
success: =>
console.log("UserListView: Collection fetched")
return
)
return
return UserListView
UserListView

View File

@@ -1,6 +1,42 @@
// 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', 'views/user/userItemView']);
define(['marionette', 'models/user/userCollection', 'views/user/userItemView', 'text!/tpl/UserListView'], function(Marionette, UserCollection, UserItemView, Template) {
var UserListView;
UserListView = (function(_super) {
__extends(UserListView, _super);
function UserListView() {
return UserListView.__super__.constructor.apply(this, arguments);
}
UserListView.prototype.template = _.template(Template);
UserListView.prototype.tagName = "table";
UserListView.prototype.className = "table table-striped";
UserListView.prototype.itemView = UserItemView;
UserListView.prototype.initialize = function() {
var _this = this;
console.log("UserListView: initialize");
this.collection = new UserCollection();
this.collection.fetch({
data: this.options,
success: function() {
console.log("UserListView: Collection fetched");
}
});
};
return UserListView;
})(Marionette.CompositeView);
return UserListView;
});
}).call(this);

View File

@@ -0,0 +1,9 @@
<td><%= profile.display_name %></td>
<td>
<a href="/user/<%= profile.slug %>"><%= profile.mix_count%></a>
</td>
<td>
<a href="/user/<%= profile.slug %>/followers"><%= profile.follower_count %></a>
</td>
<td><%= profile.following_count %></td>
<td><%= human_last_login %></td>

View File

@@ -0,0 +1,10 @@
<thead>
<tr>
<th>Name</th>
<th>Uploads</th>
<th>Followers</th>
<th>Following</th>
<th>Last seen</th>
</tr>
</thead>
<tbody></tbody>