Added file formats view
This commit is contained in:
parent
4a33278596
commit
a66873a9e2
|
@ -19,7 +19,7 @@
|
|||
{% for entry in entries %}
|
||||
<div class="row" data-id="{% if entry[0].sort %}{{entry[0].sort}}{% else %}{% if entry.name %}{{entry.name}}{% else %}{{entry[0].name}}{% endif %}{% endif %}">
|
||||
<div class="col-xs-2 col-sm-2 col-md-1" align="left"><span class="badge">{{entry.count}}</span></div>
|
||||
<div class="col-xs-10 col-sm-10 col-md-11"><a id="list_{{loop.index0}}" href="{{url_for(folder, book_id=entry[0].id )}}">
|
||||
<div class="col-xs-10 col-sm-10 col-md-11"><a id="list_{{loop.index0}}" href="{% if entry.format %}{{url_for(folder, book_id=entry.format )}}{% else %}{{url_for(folder, book_id=entry[0].id )}}{% endif %}">
|
||||
{% if entry.name %}
|
||||
<div class="rating">
|
||||
{% for number in range(entry.name) %}
|
||||
|
@ -31,7 +31,11 @@
|
|||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %} {{entry[0].name}}{% endif %}</a></div>
|
||||
{% else %}
|
||||
{% if entry.format %}
|
||||
{{entry.format}}
|
||||
{% else %}
|
||||
{{entry[0].name}}{% endif %}{% endif %}</a></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
|
@ -71,6 +71,7 @@ SIDEBAR_SORTED = 1024
|
|||
MATURE_CONTENT = 2048
|
||||
SIDEBAR_PUBLISHER = 4096
|
||||
SIDEBAR_RATING = 8192
|
||||
SIDEBAR_FORMAT = 16384
|
||||
|
||||
UPDATE_STABLE = 0
|
||||
AUTO_UPDATE_STABLE = 1
|
||||
|
@ -143,9 +144,13 @@ def get_sidebar_config(kwargs=[]):
|
|||
sidebar.append({"glyph": "glyphicon-star-empty", "text": _('Ratings'), "link": 'web.ratings_list', "id": "rate",
|
||||
"visibility": SIDEBAR_RATING, 'public': True,
|
||||
"page": "rating", "show_text": _('Show ratings selection'), "config_show":True})
|
||||
sidebar.append({"glyph": "glyphicon-file", "text": _('File formats'), "link": 'web.formats_list', "id": "format",
|
||||
"visibility": SIDEBAR_FORMAT, 'public': True,
|
||||
"page": "format", "show_text": _('Show file formats selection'), "config_show":True})
|
||||
return sidebar
|
||||
|
||||
|
||||
|
||||
class UserBase:
|
||||
|
||||
@property
|
||||
|
@ -847,7 +852,7 @@ def create_admin_user():
|
|||
user.role = ROLE_USER + ROLE_ADMIN + ROLE_DOWNLOAD + ROLE_UPLOAD + ROLE_EDIT + ROLE_DELETE_BOOKS + ROLE_PASSWD
|
||||
user.sidebar_view = DETAIL_RANDOM + SIDEBAR_LANGUAGE + SIDEBAR_SERIES + SIDEBAR_CATEGORY + SIDEBAR_HOT + \
|
||||
SIDEBAR_RANDOM + SIDEBAR_AUTHOR + SIDEBAR_BEST_RATED + SIDEBAR_READ_AND_UNREAD + SIDEBAR_RECENT + \
|
||||
SIDEBAR_SORTED + + MATURE_CONTENT + SIDEBAR_PUBLISHER + SIDEBAR_RATING
|
||||
SIDEBAR_SORTED + MATURE_CONTENT + SIDEBAR_PUBLISHER + SIDEBAR_RATING + SIDEBAR_FORMAT
|
||||
|
||||
user.password = generate_password_hash(DEFAULT_PASS)
|
||||
|
||||
|
|
30
cps/web.py
30
cps/web.py
|
@ -722,7 +722,6 @@ def series(book_id, page):
|
|||
abort(404)
|
||||
|
||||
|
||||
# (cast(db.Ratings.rating/2, SQLString)).label('name'))\
|
||||
@web.route("/ratings")
|
||||
@login_required_if_no_ano
|
||||
def ratings_list():
|
||||
|
@ -746,7 +745,34 @@ def ratings(book_id, page):
|
|||
entries, random, pagination = fill_indexpage(page, db.Books, db.Books.ratings.any(db.Ratings.id == book_id),
|
||||
[db.Books.timestamp.desc()])
|
||||
return render_title_template('index.html', random=random, pagination=pagination, entries=entries,
|
||||
title=_(u"Ratings: %(rating)s stars", rating=(name.rating/2)), page="ratings")
|
||||
title=_(u"Rating: %(rating)s stars", rating=int(name.rating/2)), page="ratings")
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
|
||||
@web.route("/formats")
|
||||
@login_required_if_no_ano
|
||||
def formats_list():
|
||||
if current_user.check_visibility(ub.SIDEBAR_FORMAT):
|
||||
entries = db.session.query(db.Data, func.count('data.book').label('count'),db.Data.format.label('format'))\
|
||||
.join(db.Books).filter(common_filters())\
|
||||
.group_by(db.Data.format).order_by(db.Data.format).all()
|
||||
return render_title_template('list.html', entries=entries, folder='web.formats', charlist=list(),
|
||||
title=_(u"File formats list"), page="formatslist")
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
|
||||
@web.route("/formats/<book_id>/", defaults={'page': 1})
|
||||
@web.route("/formats/<book_id>/<int:page>")
|
||||
@login_required_if_no_ano
|
||||
def formats(book_id, page):
|
||||
name = db.session.query(db.Data).filter(db.Data.format == book_id.upper()).first()
|
||||
if name:
|
||||
entries, random, pagination = fill_indexpage(page, db.Books, db.Books.data.any(db.Data.format == book_id.upper()),
|
||||
[db.Books.timestamp.desc()])
|
||||
return render_title_template('index.html', random=random, pagination=pagination, entries=entries,
|
||||
title=_(u"File format: %(format)s", format=name.format), page="formats")
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user