mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Link to groups from user profile
This commit is contained in:
parent
2d47fe4473
commit
e511e8a80b
4 changed files with 18 additions and 0 deletions
|
@ -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) {
|
if (json.user.invited_by) {
|
||||||
json.user.invited_by = Discourse.User.create(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>
|
<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}}
|
{{#if isSuspended}}
|
||||||
<div class='suspended'>
|
<div class='suspended'>
|
||||||
<i class='fa fa-ban'></i>
|
<i class='fa fa-ban'></i>
|
||||||
|
|
|
@ -98,6 +98,10 @@ class User < ActiveRecord::Base
|
||||||
3..15
|
3..15
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def custom_groups
|
||||||
|
groups.where(automatic: false)
|
||||||
|
end
|
||||||
|
|
||||||
def self.username_available?(username)
|
def self.username_available?(username)
|
||||||
lower = username.downcase
|
lower = username.downcase
|
||||||
User.where(username_lower: lower).blank?
|
User.where(username_lower: lower).blank?
|
||||||
|
|
|
@ -22,6 +22,7 @@ class UserSerializer < BasicUserSerializer
|
||||||
:suspended_till
|
:suspended_till
|
||||||
|
|
||||||
has_one :invited_by, embed: :object, serializer: BasicUserSerializer
|
has_one :invited_by, embed: :object, serializer: BasicUserSerializer
|
||||||
|
has_many :custom_groups, embed: :object, serializer: BasicGroupSerializer
|
||||||
|
|
||||||
def self.private_attributes(*attrs)
|
def self.private_attributes(*attrs)
|
||||||
attributes(*attrs)
|
attributes(*attrs)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue