Link to groups from user profile
This commit is contained in:
parent
2d47fe4473
commit
e511e8a80b
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue