Merge pull request #1723 from vikhyat/disable-uploads

Don't show uploading forms if the relevant site settings are disabled
This commit is contained in:
Régis Hanol 2013-12-06 00:26:50 -08:00
commit a7eced3a06
4 changed files with 27 additions and 13 deletions

View file

@ -7,6 +7,10 @@
@module Discourse
**/
Discourse.PreferencesController = Discourse.ObjectController.extend({
allowAvatarUpload: function() {
return Discourse.SiteSetting.allow_uploaded_avatars;
}.property(),
// By default we haven't saved anything
saved: false,

View file

@ -8,8 +8,12 @@
@module Discourse
**/
Discourse.UploadSelectorController = Discourse.Controller.extend(Discourse.ModalFunctionality, {
local: true,
remote: Em.computed.not("local"),
local: Em.computed.not("remote"),
remote: Em.computed.not("allowLocal"),
allowLocal: function() {
return Discourse.SiteSettings.max_attachment_size_kb > 0;
}.property(),
actions: {
useLocal: function() { this.set("local", true); },

View file

@ -1,14 +1,16 @@
<div class="modal-body">
<div class="radios">
<input type="radio" id="local" value="local" name="upload" {{action useLocal}}>
<label class="radio" for="local">{{i18n upload_selector.from_my_computer}}</label>
{{#if controller.local}}
<div class="inputs">
<input type="file" id="filename-input"><br>
<span class="description">{{unbound view.tip}}</span>
</div>
{{/if}}
</div>
{{#if allowLocal}}
<div class="radios">
<input type="radio" id="local" value="local" name="upload" {{action useLocal}}>
<label class="radio" for="local">{{i18n upload_selector.from_my_computer}}</label>
{{#if controller.local}}
<div class="inputs">
<input type="file" id="filename-input"><br>
<span class="description">{{unbound view.tip}}</span>
</div>
{{/if}}
</div>
{{/if}}
<div class="radios">
<input type="radio" id="remote" value="remote" name="upload" {{action useRemote}}>
<label class="radio" for="remote">{{i18n upload_selector.from_the_web}}</label>

View file

@ -49,7 +49,11 @@
<label class="control-label">{{i18n user.avatar.title}}</label>
<div class="controls">
{{boundAvatar model imageSize="large"}}
<button {{action showAvatarSelector}} class="btn pad-left"><i class="icon-pencil"></i></button>
{{#if allowAvatarUpload}}
<button {{action showAvatarSelector}} class="btn pad-left"><i class="icon-pencil"></i></button>
{{else}}
<a href="//gravatar.com/emails" target="_blank" title="{{i18n user.change_avatar.gravatar_title}}" class="btn"><i class="icon-pencil"></i></a>
{{/if}}
</div>
</div>