Tie visibility of upload buttons to upload right only

This commit is contained in:
Ozzie Isaacs
2021-11-27 17:43:51 +01:00
parent ec7c2db971
commit 7f9da94a18
5 changed files with 340 additions and 164 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ log = logger.create()
def upload_required(f):
@wraps(f)
def inner(*args, **kwargs):
if current_user.role_upload() or current_user.role_admin():
if current_user.role_upload():
return f(*args, **kwargs)
abort(403)
+2 -6
View File
@@ -98,8 +98,7 @@
<label for="rating">{{_('Rating')}}</label>
<input type="number" name="rating" id="rating" class="rating input-lg" data-clearable="" value="{% if book.ratings %}{{(book.ratings[0].rating / 2)|int}}{% endif %}">
</div>
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %}
{% if g.user.role_upload() and g.allow_upload %}
<div class="form-group">
<label for="cover_url">{{_('Fetch Cover from URL (JPEG - Image will be downloaded and stored in database)')}}</label>
<input type="text" class="form-control" name="cover_url" id="cover_url" value="">
@@ -109,7 +108,6 @@
<div class="upload-cover-input-text" id="upload-cover"></div>
<input id="btn-upload-cover" name="btn-upload-cover" type="file" accept=".jpg, .jpeg, .png, .webp">
</div>
{% endif %}
{% endif %}
<label for="pubdate">{{_('Published Date')}}</label>
<div class="form-group input-group">
@@ -197,14 +195,12 @@
</div>
{% endfor %}
{% endif %}
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %}
{% if g.user.role_upload() and g.allow_upload %}
<div role="group" aria-label="Upload new book format">
<label class="btn btn-primary btn-file" for="btn-upload-format">{{ _('Upload Format') }}</label>
<div class="upload-format-input-text" id="upload-format"></div>
<input id="btn-upload-format" name="btn-upload-format" type="file">
</div>
{% endif %}
{% endif %}
<div class="checkbox">
+1 -1
View File
@@ -105,7 +105,7 @@
</div>
<div class="form-group">
<input type="checkbox" id="config_uploading" data-control="upload_settings" name="config_uploading" {% if config.config_uploading %}checked{% endif %}>
<label for="config_uploading">{{_('Enable Uploads')}}</label>
<label for="config_uploading">{{_('Enable Uploads')}} {{_('(Please ensure users having also upload rights)')}}</label>
</div>
<div data-related="upload_settings">
<div class="form-group">
+1 -3
View File
@@ -58,8 +58,7 @@
{% endif %}
<ul class="nav navbar-nav navbar-right" id="main-nav">
{% if g.user.is_authenticated or g.allow_anonymous %}
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %}
{% if g.user.role_upload() and g.allow_upload %}
<li>
<form id="form-upload" class="navbar-form" action="{{ url_for('editbook.upload') }}" data-title="{{_('Uploading...')}}" data-footer="{{_('Close')}}" data-failed="{{_('Error')}}" data-message="{{_('Upload done, processing, please wait...')}}" method="post" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
@@ -69,7 +68,6 @@
</div>
</form>
</li>
{% endif %}
{% endif %}
{% if not g.user.is_anonymous %}
<li><a id="top_tasks" href="{{url_for('web.get_tasks_status')}}"><span class="glyphicon glyphicon-tasks"></span> <span class="hidden-sm">{{_('Tasks')}}</span></a></li>