Link to groups from user profile

This commit is contained in:
Robin Ward 2014-02-06 17:34:48 -05:00
parent 2d47fe4473
commit e511e8a80b
4 changed files with 18 additions and 0 deletions

View File

@ -288,6 +288,11 @@ Discourse.User = Discourse.Model.extend({
}));
}
if (!Em.isEmpty(json.user.custom_groups)) {
json.user.custom_groups = json.user.custom_groups.map(function (g) {
return Discourse.Group.create(g);
});
}
if (json.user.invited_by) {
json.user.invited_by = Discourse.User.create(json.user.invited_by);
}

View File

@ -43,6 +43,14 @@
<div class='bio'>{{{bio_cooked}}}</div>
{{#if custom_groups}}
<div class='groups'>
{{#each custom_groups}}
{{#link-to 'group' this}}{{name}}{{/link-to}}
{{/each}}
</div>
{{/if}}
{{#if isSuspended}}
<div class='suspended'>
<i class='fa fa-ban'></i>

View File

@ -98,6 +98,10 @@ class User < ActiveRecord::Base
3..15
end
def custom_groups
groups.where(automatic: false)
end
def self.username_available?(username)
lower = username.downcase
User.where(username_lower: lower).blank?

View File

@ -22,6 +22,7 @@ class UserSerializer < BasicUserSerializer
:suspended_till
has_one :invited_by, embed: :object, serializer: BasicUserSerializer
has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer
def self.private_attributes(*attrs)
attributes(*attrs)