Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master:
  FIX: categories created by users who are deleted cannot be deleted
  Site setting to support showing real names in posts. Also put back in type to search on site settings
  Adjust ul,ol margins
  main logo size consistency fix
  FIX: Non-Admins couldn't send private messages through the new user expansion
  • Loading branch information
rwdaigle committed Nov 1, 2013
2 parents efbc800 + e679ba9 commit 0f0af92
Show file tree
Hide file tree
Showing 29 changed files with 69 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.P
}

var adminSettingsController = this;
return this.get('content').filter(function(item, index, enumerable) {

var maxResults = Em.isNone(filter) ? this.get('content.length') : 20;
return _.first(this.get('content').filter(function(item, index, enumerable) {
if (adminSettingsController.get('onlyOverridden') && !item.get('overridden')) return false;
if (filter) {
if (item.get('setting').toLowerCase().indexOf(filter) > -1) return true;
Expand All @@ -36,20 +38,11 @@ Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.P
}

return true;
});
}), maxResults);
}.property('filter', 'content.@each', 'onlyOverridden'),

actions: {

/**
Changes the currently active filter
@method changeFilter
**/
changeFilter: function() {
this.set('filter', this.get('newFilter'));
},

/**
Reset a setting to its default value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
</label>
</div>
<div class='controls'>
{{textField value=newFilter}}
<button class="btn btn-primary" {{action changeFilter}}>{{i18n filter}}</button>
{{textField value=filter placeholderKey="type_to_filter"}}
</div>

</div>
Expand Down
5 changes: 5 additions & 0 deletions app/assets/javascripts/discourse/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Discourse.Post = Discourse.Model.extend({
notDeleted: Em.computed.not('deleted'),
userDeleted: Em.computed.empty('user_id'),

showName: function() {
var name = this.get('name');
return name && (name !== this.get('username')) && Discourse.SiteSettings.display_name_on_posts;
}.property('name', 'username'),

postDeletedBy: function() {
if (this.get('firstPost')) { return this.get('topic.deleted_by'); }
return this.get('deleted_by');
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/discourse/routes/topic_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Discourse.TopicRoute = Discourse.Route.extend({

composePrivateMessage: function(user) {
var self = this;
this.transitionTo('userPrivateMessages', user).then(function () {
this.transitionTo('userActivity', user).then(function () {
self.controllerFor('userActivity').send('composePrivateMessage');
});
},
Expand Down
5 changes: 5 additions & 0 deletions app/assets/javascripts/discourse/templates/post.js.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<div {{bindAttr class=":contents byTopicCreator:topic-creator :trigger-expansion"}}>
<a href='{{unbound usernameUrl}}' {{action showPosterExpansion this}}>{{avatar this imageSize="large"}}</a>
<h3 {{bindAttr class="staff new_user"}}><a href='{{unbound usernameUrl}}' {{action showPosterExpansion this}}>{{breakUp username}}</a></h3>

{{#if showName}}
<h3><a href='{{unbound usernameUrl}}' {{action showPosterExpansion this}}>{{breakUp name}}</a></h3>
{{/if}}

{{#if user_title}}<div class="user-title" {{action showPosterExpansion this}}>{{user_title}}</div>{{/if}}
</div>
{{else}}
Expand Down
3 changes: 1 addition & 2 deletions app/assets/stylesheets/desktop/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
}
}
#site-logo {
max-height: 40px;
max-width: 350px;
width: 122px;
}
.icon-home {
font-size: 20px;
Expand Down
16 changes: 8 additions & 8 deletions app/assets/stylesheets/desktop/topic-post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ h1 .topic-statuses .topic-status i {margin-right: 5px;}
margin-left: -8px;
}

.avoid-tab {
.avoid-tab {
padding-top: 25px;
.topic-meta-data-inside {margin-top: -30px;}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ nav.post-controls {
border: none;
margin-left: 3px;
transition: all linear 0.15s;
outline: none;
outline: none;
&:hover {
background: #eee;
color: #888;
Expand Down Expand Up @@ -394,12 +394,12 @@ span.post-count {
#topic-title {
z-index: 1000;
padding: 14px 0 8px 0;
h1 {
line-height: 1.2em;
overflow: hidden;
h1 {
line-height: 1.2em;
overflow: hidden;
}
.topic-statuses {
margin-top: -2px;
margin-top: -2px;
.icon-pushpin {margin-top: -1px;}
}
.star {font-size: 20px; margin-top: 8px;}
Expand Down Expand Up @@ -435,7 +435,7 @@ iframe {
}

.extra-info-wrapper {
float: left;
float: left;
width: 78%;
.topic-statuses {margin-right: 5px;}
}
Expand Down Expand Up @@ -499,7 +499,7 @@ iframe {
.contents .cooked {
padding-right: 30px;
h1, h2, h3 {margin: 10px 0;}
ul, ol {margin: 15px 0;}
ul, ol {margin: 0 15px;}
li p {margin: 3px 0;}
}

Expand Down
1 change: 1 addition & 0 deletions app/models/site_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class SiteSetting < ActiveRecord::Base
# hidden setting only used by system
setting(:uncategorized_category_id, -1, hidden: true)

client_setting(:display_name_on_posts, false)
client_setting(:enable_names, true)

def self.call_discourse_hub?
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ cs:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "zadejte text pro filtrování..."

admin:
title: 'Discourse Administrace'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.da.yml
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ da:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "type to filter..."

admin:
title: 'Discourse Admin'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ de:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "Tippe etwas ein, um zu filtern..."

admin:
title: 'Discourse Administrator'
Expand Down
2 changes: 1 addition & 1 deletion config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ en:

# This section is exported to the javascript for i18n in the admin section
admin_js:
filter: "filter"
type_to_filter: "type to filter..."

admin:
title: 'Discourse Admin'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ es:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "type to filter..."

admin:
title: 'Administrador'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ fr:
create_post: "Répondre / Voir"
readonly: "Voir"
admin_js:
type_to_filter: "Commencez à taper pour filtrer..."
admin:
title: 'Administation Discourse'
moderator: 'Modérateur'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ id:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "type to filter..."

admin:
title: 'Discourse Admin'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ it:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "scrivi per filtrare..."

admin:
title: 'Amministrazione Discourse'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ ko:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "필터를 입력하세요"

admin:
title: 'Discourse 관리자'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.nb_NO.yml
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ nb_NO:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "skriv for å filtrere..."

admin:
title: 'Discourse Admin'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ nl:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: typ om te filteren...

admin:
title: Discourse Beheer
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.pseudo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ pseudo:
ƀřóŵšéř íš ťóó ółď ťó ŵóřǩ óɳ ťĥíš Ďíščóůřšé ƒóřůɱ</á>. Рłéášé <á ĥřéƒ="ĥťťƿ://ƀřóŵšéĥáƿƿý.čóɱ">ůƿǧřáďé
ýóůř ƀřóŵšéř</á>. ]]'
admin_js:
type_to_filter: '[[ ťýƿé ťó ƒíłťéř... ]]'
admin:
title: '[[ Ďíščóůřšé Áďɱíɳ ]]'
moderator: '[[ Ϻóďéřáťóř ]]'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ pt:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "escreve para filtrar..."

admin:
title: 'Discourse Admin'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.pt_BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,7 @@ pt_BR:

# Essa seção é para o javascript para i18n no admin
admin_js:
type_to_filter: "escreva para filtrar..."

admin:
title: 'Discourse Admin'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ ru:
create_post: 'Отвечать / Просматривать'
readonly: Просматривать
admin_js:
type_to_filter: 'Введите текст для фильтрации...'
admin:
title: 'Discourse Admin'
moderator: Модератор
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ sv:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "skriv för att filtrera..."

admin:
title: 'Discourse Admin'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.zh_CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ zh_CN:

# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "输入过滤条件……"

admin:
title: '论道 管理'
Expand Down
1 change: 1 addition & 0 deletions config/locales/client.zh_TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ zh_TW:
readonly: "觀看"
# This section is exported to the javascript for i18n in the admin section
admin_js:
type_to_filter: "輸入過濾條件……"

admin:
title: '論道 管理'
Expand Down
1 change: 1 addition & 0 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ en:
dominating_topic_minimum_percent: "What percentage of posts a user has to make in a topic before we consider it dominating."

enable_names: "Allow users to show their full names"
display_name_on_posts: "Also show a user's full name on their posts"

notification_types:
mentioned: "%{display_username} mentioned you in %{link}"
Expand Down
13 changes: 13 additions & 0 deletions lib/user_destroyer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ def destroy(user, opts={})
b.record_match! if b
end
Post.with_deleted.where(user_id: user.id).update_all("user_id = NULL")

# If this user created categories, fix those up:
categories = Category.where(user_id: user.id).all
categories.each do |c|
c.user_id = Discourse.system_user.id
c.save!
if topic = Topic.with_deleted.where(id: c.topic_id).first
topic.try(:recover!)
topic.user_id = Discourse.system_user.id
topic.save!
end
end

StaffActionLogger.new(@staff).log_user_deletion(user, opts.slice(:context))
DiscourseHub.unregister_nickname(user.username) if SiteSetting.call_discourse_hub?
MessageBus.publish "/file-change", ["refresh"], user_ids: [user.id]
Expand Down
11 changes: 11 additions & 0 deletions spec/components/user_destroyer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@
UserDestroyer.new(@admin).destroy(@user, {block_ip: true})
end
end

context 'user created a category' do
let!(:category) { Fabricate(:category, user: @user) }

it "assigns the system user to the categories" do
UserDestroyer.new(@admin).destroy(@user, {delete_posts: true})
category.reload.user_id.should == Discourse.system_user.id
category.topic.should be_present
category.topic.user_id.should == Discourse.system_user.id
end
end
end

end

0 comments on commit 0f0af92

Please sign in to comment.