Merge pull request #4588 from tgxworld/add_new_fields_to_group
Add new fields to group
This commit is contained in:
commit
ce9f24dec9
|
@ -11,6 +11,11 @@
|
||||||
|
|
||||||
{{#if model.id}}
|
{{#if model.id}}
|
||||||
{{#unless model.automatic}}
|
{{#unless model.automatic}}
|
||||||
|
<div>
|
||||||
|
<label for="bio">{{i18n 'group.bio'}}</label>
|
||||||
|
{{d-editor value=model.bio_raw}}
|
||||||
|
</div>
|
||||||
|
|
||||||
{{#if model.hasOwners}}
|
{{#if model.hasOwners}}
|
||||||
<div>
|
<div>
|
||||||
<label for='owner-list'>{{i18n 'admin.groups.group_owners'}}</label>
|
<label for='owner-list'>{{i18n 'admin.groups.group_owners'}}</label>
|
||||||
|
|
|
@ -114,6 +114,7 @@ const Group = Discourse.Model.extend({
|
||||||
flair_url: this.get('flair_url'),
|
flair_url: this.get('flair_url'),
|
||||||
flair_bg_color: this.get('flairBackgroundHexColor'),
|
flair_bg_color: this.get('flairBackgroundHexColor'),
|
||||||
flair_color: this.get('flairHexColor'),
|
flair_color: this.get('flairHexColor'),
|
||||||
|
bio_raw: this.get('bio_raw')
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,5 @@
|
||||||
<div class="container group">
|
<div class="container group">
|
||||||
<div class='pull-left group-nav'>
|
<div class='group-details-container'>
|
||||||
<ul class='nav-stacked'>
|
|
||||||
{{#each getTabs as |tab|}}
|
|
||||||
<li class="{{if tab.active 'active'}}">
|
|
||||||
{{#link-to tab.location model title=tab.message}}
|
|
||||||
{{tab.message}}
|
|
||||||
{{#if tab.count}}<span class='count'>({{tab.count}})</span>{{/if}}
|
|
||||||
{{/link-to}}
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class='pull-left group-outlet'>
|
|
||||||
<div class='group-details'>
|
<div class='group-details'>
|
||||||
<span>
|
<span>
|
||||||
<h1 class='group-header'>
|
<h1 class='group-header'>
|
||||||
|
@ -31,11 +18,32 @@
|
||||||
|
|
||||||
{{#if canEditGroup}}
|
{{#if canEditGroup}}
|
||||||
<span>
|
<span>
|
||||||
{{d-button action="showGroupEditor" class="group-edit-btn btn-small" icon="pencil"}}
|
{{d-button action="showGroupEditor" label="group.edit.title" class="group-edit-btn" icon="pencil"}}
|
||||||
</span>
|
</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{#if model.bio_cooked}}
|
||||||
|
<div class='group-bio'>
|
||||||
|
<p>{{{model.bio_cooked}}}</p>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='pull-left group-nav'>
|
||||||
|
<ul class='nav-stacked'>
|
||||||
|
{{#each getTabs as |tab|}}
|
||||||
|
<li class="{{if tab.active 'active'}}">
|
||||||
|
{{#link-to tab.location model title=tab.message}}
|
||||||
|
{{tab.message}}
|
||||||
|
{{#if tab.count}}<span class='count'>({{tab.count}})</span>{{/if}}
|
||||||
|
{{/link-to}}
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='pull-left group-outlet'>
|
||||||
<div class='user-main'>
|
<div class='user-main'>
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
{{#d-modal-body title="group.edit.title" class="edit-group groups"}}
|
{{#d-modal-body title="group.edit.title" class="edit-group groups"}}
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
|
<label for='bio'>{{i18n 'group.bio'}}</label>
|
||||||
|
{{d-editor value=model.bio_raw class="edit-group-bio"}}
|
||||||
|
|
||||||
{{group-flair-inputs model=model}}
|
{{group-flair-inputs model=model}}
|
||||||
</form>
|
</form>
|
||||||
{{/d-modal-body}}
|
{{/d-modal-body}}
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.group-details-container {
|
||||||
|
background: rgba(230, 230, 230, 0.3);
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
table.group-members {
|
table.group-members {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
@ -30,6 +36,10 @@ table.group-members {
|
||||||
color: $primary;
|
color: $primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.group-details {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.group-header, .group-details {
|
.group-header, .group-details {
|
||||||
display: table;
|
display: table;
|
||||||
|
|
||||||
|
@ -53,9 +63,14 @@ table.group-members {
|
||||||
|
|
||||||
.group-edit-btn {
|
.group-edit-btn {
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.groups.edit-group .form-horizontal {
|
||||||
|
textarea {
|
||||||
|
width: 99%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-horizontal {
|
|
||||||
label {
|
label {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +106,8 @@ table.group-members {
|
||||||
}
|
}
|
||||||
|
|
||||||
#add-user-to-group {
|
#add-user-to-group {
|
||||||
|
margin: 0px;
|
||||||
|
|
||||||
.ac-wrap {
|
.ac-wrap {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,12 @@ class GroupsController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def group_params
|
def group_params
|
||||||
params.require(:group).permit(:flair_url, :flair_bg_color, :flair_color)
|
params.require(:group).permit(
|
||||||
|
:flair_url,
|
||||||
|
:flair_bg_color,
|
||||||
|
:flair_color,
|
||||||
|
:bio_raw
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_group(param_name)
|
def find_group(param_name)
|
||||||
|
|
|
@ -13,6 +13,7 @@ class Group < ActiveRecord::Base
|
||||||
has_and_belongs_to_many :web_hooks
|
has_and_belongs_to_many :web_hooks
|
||||||
|
|
||||||
before_save :downcase_incoming_email
|
before_save :downcase_incoming_email
|
||||||
|
before_save :cook_bio
|
||||||
|
|
||||||
after_save :destroy_deletions
|
after_save :destroy_deletions
|
||||||
after_save :automatic_group_membership
|
after_save :automatic_group_membership
|
||||||
|
@ -83,6 +84,12 @@ class Group < ActiveRecord::Base
|
||||||
self.incoming_email = (incoming_email || "").strip.downcase.presence
|
self.incoming_email = (incoming_email || "").strip.downcase.presence
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cook_bio
|
||||||
|
if !self.bio_raw.blank?
|
||||||
|
self.bio_cooked = PrettyText.cook(self.bio_raw)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def incoming_email_validator
|
def incoming_email_validator
|
||||||
return if self.automatic || self.incoming_email.blank?
|
return if self.automatic || self.incoming_email.blank?
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,25 @@ class BasicGroupSerializer < ApplicationSerializer
|
||||||
:has_messages,
|
:has_messages,
|
||||||
:flair_url,
|
:flair_url,
|
||||||
:flair_bg_color,
|
:flair_bg_color,
|
||||||
:flair_color
|
:flair_color,
|
||||||
|
:bio_raw,
|
||||||
|
:bio_cooked
|
||||||
|
|
||||||
def include_incoming_email?
|
def include_incoming_email?
|
||||||
scope.is_staff?
|
staff?
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_has_messsages
|
||||||
|
staff?
|
||||||
|
end
|
||||||
|
|
||||||
|
def include_bio_raw
|
||||||
|
staff?
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def staff?
|
||||||
|
@staff ||= scope.is_staff?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1849,6 +1849,7 @@ en:
|
||||||
edit:
|
edit:
|
||||||
title: 'Edit Group'
|
title: 'Edit Group'
|
||||||
name: "Name"
|
name: "Name"
|
||||||
|
bio: "About Group"
|
||||||
name_placeholder: "Group name, no spaces, same as username rule"
|
name_placeholder: "Group name, no spaces, same as username rule"
|
||||||
flair_url: "Avatar Flair Image"
|
flair_url: "Avatar Flair Image"
|
||||||
flair_url_placeholder: "(Optional) Image URL or Font Awesome class"
|
flair_url_placeholder: "(Optional) Image URL or Font Awesome class"
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddBioToGroups < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :groups, :bio_raw, :text
|
||||||
|
add_column :groups, :bio_cooked, :text
|
||||||
|
end
|
||||||
|
end
|
|
@ -46,7 +46,8 @@ describe "Groups" do
|
||||||
xhr :put, "/groups/#{group.id}", { group: {
|
xhr :put, "/groups/#{group.id}", { group: {
|
||||||
flair_bg_color: 'FFF',
|
flair_bg_color: 'FFF',
|
||||||
flair_color: 'BBB',
|
flair_color: 'BBB',
|
||||||
flair_url: 'fa-adjust'
|
flair_url: 'fa-adjust',
|
||||||
|
bio_raw: 'testing'
|
||||||
} }
|
} }
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
|
@ -56,6 +57,7 @@ describe "Groups" do
|
||||||
expect(group.flair_bg_color).to eq('FFF')
|
expect(group.flair_bg_color).to eq('FFF')
|
||||||
expect(group.flair_color).to eq('BBB')
|
expect(group.flair_color).to eq('BBB')
|
||||||
expect(group.flair_url).to eq('fa-adjust')
|
expect(group.flair_url).to eq('fa-adjust')
|
||||||
|
expect(group.bio_raw).to eq('testing')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -322,7 +322,6 @@ describe Group do
|
||||||
expect(Group.desired_trust_level_groups(2).sort).to eq [10,11,12]
|
expect(Group.desired_trust_level_groups(2).sort).to eq [10,11,12]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it "correctly handles trust level changes" do
|
it "correctly handles trust level changes" do
|
||||||
user = Fabricate(:user, trust_level: 2)
|
user = Fabricate(:user, trust_level: 2)
|
||||||
Group.user_trust_level_change!(user.id, 2)
|
Group.user_trust_level_change!(user.id, 2)
|
||||||
|
@ -369,4 +368,11 @@ describe Group do
|
||||||
expect(u3.reload.trust_level).to eq(3)
|
expect(u3.reload.trust_level).to eq(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should cook the bio' do
|
||||||
|
group = Fabricate(:group)
|
||||||
|
group.update_attributes!(bio_raw: 'This is a group for :unicorn: lovers')
|
||||||
|
|
||||||
|
expect(group.bio_cooked).to include("unicorn.png")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,5 +46,6 @@ test("Admin Browsing Groups", () => {
|
||||||
|
|
||||||
andThen(() => {
|
andThen(() => {
|
||||||
ok(find('.group-flair-inputs').length === 1, 'it should display avatar flair inputs');
|
ok(find('.group-flair-inputs').length === 1, 'it should display avatar flair inputs');
|
||||||
|
ok(find('.edit-group-bio').length === 1, 'it should display group bio input');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue