1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 19:40:00 +00:00

fix #173 and add avatar to mod user info

add rank color to username everywhere
some other minor changes
This commit is contained in:
nyaadev 2017-05-24 00:28:17 +02:00
parent a88f6a0847
commit 020a0871bd
7 changed files with 52 additions and 49 deletions

View file

@ -411,8 +411,10 @@ class User(db.Model):
return 'User' return 'User'
elif self.level == UserLevelType.TRUSTED: elif self.level == UserLevelType.TRUSTED:
return 'Trusted' return 'Trusted'
elif self.level >= UserLevelType.MODERATOR: elif self.level == UserLevelType.MODERATOR:
return 'Moderator' return 'Moderator'
elif self.level == UserLevelType.SUPERADMIN:
return 'Administrator'
@property @property
def userlevel_color(self): def userlevel_color(self):

View file

@ -480,8 +480,6 @@ def profile():
form = forms.ProfileForm(flask.request.form) form = forms.ProfileForm(flask.request.form)
level = ['Regular', 'Trusted', 'Moderator', 'Administrator'][flask.g.user.level]
if flask.request.method == 'POST' and form.validate(): if flask.request.method == 'POST' and form.validate():
user = flask.g.user user = flask.g.user
new_email = form.email.data.strip() new_email = form.email.data.strip()
@ -511,12 +509,7 @@ def profile():
flask.g.user = user flask.g.user = user
return flask.redirect('/profile') return flask.redirect('/profile')
_user = models.User.by_id(flask.g.user.id) return flask.render_template('profile.html', form=form)
username = _user.username
current_email = _user.email
return flask.render_template('profile.html', form=form, name=username, email=current_email,
level=level)
@app.route('/user/activate/<payload>') @app.route('/user/activate/<payload>')

View file

@ -258,15 +258,16 @@ a.text-purple:hover, a.text-purple:active, a.text-purple:focus { color: #a760e0;
} }
.btn-grey { .btn-grey {
color: #000000; color: #000000;
background-color: #cccfd2; background-color: #cccfd2;
border-color: #ccc; border-color: #ccc;
} }
.btn-grey:hover, .btn-grey:focus, .btn-grey:active, .btn-grey.active, .open > .dropdown-toggle.btn-grey { .btn-grey:hover, .btn-grey:focus, .btn-grey:active, .btn-grey.active, .open > .dropdown-toggle.btn-grey {
background-color: #aaaaaa; background-color: #aaaaaa;
} }
.btn span.glyphicon { .btn span.glyphicon {
opacity: 0; opacity: 0;
} }
.btn.active span.glyphicon { .btn.active span.glyphicon {
opacity: 1; opacity: 1;
}

View file

@ -27,7 +27,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
<!-- Custom styles for this template --> <!-- Custom styles for this template -->
<link href="/static/css/main.css?v=3" rel="stylesheet"> <link href="/static/css/main.css?v=4" rel="stylesheet">
<!-- Core JavaScript --> <!-- Core JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
@ -82,7 +82,7 @@
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle visible-lg visible-sm visible-xs" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> <a href="#" class="dropdown-toggle visible-lg visible-sm visible-xs" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-user fa-fw"></i> <i class="fa fa-user fa-fw"></i>
{{g.user.username}} {{ g.user.username }}
<span class="caret"></span> <span class="caret"></span>
</a> </a>
<a href="#" class="dropdown-toggle hidden-lg hidden-sm hidden-xs" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> <a href="#" class="dropdown-toggle hidden-lg hidden-sm hidden-xs" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">

View file

@ -3,17 +3,17 @@
{% block body %} {% block body %}
{% from "_formhelpers.html" import render_field %} {% from "_formhelpers.html" import render_field %}
<h2 style="margin-bottom: 20px;">Profile of <strong>{{ name }}</strong></h2> <h2 style="margin-bottom: 20px;">Profile of <strong class="text-{{ g.user.userlevel_color }}">{{ g.user.username }}</strong></h2>
<div class="row"> <div class="row" style="margin-bottom: 20px;">
<div class="col-sm-4 avatar" style="display: none;"> <div class="col-sm-2" style="max-width: 150px;">
<!-- TO BE IMPLEMENTED --> <img class="avatar" src="{{ g.user.gravatar_url() }}">
</div> </div>
<div class="col-sm-8"> <div class="col-sm-10">
<dl class="row" style="margin: 20px 0 15px 0;"> <dl class="row" style="margin: 20px 0 15px 0;">
<dt class="col-sm-3">User ID:</dt><dd class="col-sm-9">{{ g.user.id }}</dd> <dt class="col-sm-2">User ID:</dt><dd class="col-sm-10">{{ g.user.id }}</dd>
<dt class="col-sm-3">User Class:</dt><dd class="col-sm-9">{{ level }}</dd> <dt class="col-sm-2">User Class:</dt><dd class="col-sm-10">{{ g.user.userlevel_str }}</dd>
<dt class="col-sm-3">User Created on:</dt><dd class="col-sm-9">{{ g.user.created_time }}</dd> <dt class="col-sm-2">User Created on:</dt><dd class="col-sm-10">{{ g.user.created_time }}</dd>
</dl> </dl>
</div> </div>
</div> </div>
@ -59,7 +59,7 @@
<div class="row"> <div class="row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label class="control-label" for="current_email">Current Email</label> <label class="control-label" for="current_email">Current Email</label>
<div>{{email}}</div> <div>{{ g.user.email }}</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View file

@ -5,20 +5,27 @@
{% if g.user and g.user.is_moderator %} {% if g.user and g.user.is_moderator %}
<h2>User Information</h2><br> <h2>User Information</h2><br>
<dl class="dl-horizontal"> <div class="row" style="margin-bottom: 20px;">
<dt>User ID:</dt> <div class="col-sm-2" style="max-width: 150px;">
<dd>{{ user.id }}</dd> <img class="avatar" src="https://nyaa.si/static/img/avatar/default.png">
<dt>Account created on:</dt> </div>
<dd>{{ user.created_time }}</dd> <div class="col-sm-10">
<dt>Email address:</dt> <dl class="dl-horizontal">
<dd>{{ user.email }}</dd> <dt>User ID:</dt>
<dt>User class:</dt> <dd>{{ user.id }}</dd>
<dd>{{ level }}</dd> <dt>Account created on:</dt>
{%- if g.user.is_superadmin -%} <dd>{{ user.created_time }}</dd>
<dt>Last login IP:</dt> <dt>Email address:</dt>
<dd>{{ user.ip_string }}</dd><br> <dd>{{ user.email }}</dd>
{%- endif -%} <dt>User class:</dt>
</dl> <dd>{{ level }}</dd>
{%- if g.user.is_superadmin -%}
<dt>Last login IP:</dt>
<dd>{{ user.ip_string }}</dd><br>
{%- endif -%}
</dl>
</div>
</div>
{% if admin_form %} {% if admin_form %}
<form method="POST"> <form method="POST">
{{ admin_form.csrf_token }} {{ admin_form.csrf_token }}
@ -34,7 +41,7 @@
{% endif %} {% endif %}
<h3> <h3>
Browsing {{ user.username }}'s torrents Browsing <span class="text-{{ user.userlevel_color }}">{{ user.username }}</span>'s torrents
</h3> </h3>
{% include "search_results.html" %} {% include "search_results.html" %}

View file

@ -25,15 +25,15 @@
<div class="row"> <div class="row">
<div class="col-md-1">Submitter:</div> <div class="col-md-1">Submitter:</div>
<div class="col-md-5"> <div class="col-md-5">
{% set user_url = torrent.user and url_for('view_user', user_name=torrent.user.username) %} {% set user_url = torrent.user and url_for('view_user', user_name=torrent.user.username) %}
{%- if not torrent.anonymous and torrent.user -%} {%- if not torrent.anonymous and torrent.user -%}
<a href="{{ user_url }}">{{ torrent.user.username }}</a> <a class="text-{{ torrent.user.userlevel_color }}" href="{{ user_url }}">{{ torrent.user.username }}</a>
{%- else -%} {%- else -%}
Anonymous {% if torrent.user and (g.user == torrent.user or g.user.is_moderator) %}(<a href="{{ user_url }}">{{ torrent.user.username }}</a>){% endif %} Anonymous {% if torrent.user and (g.user == torrent.user or g.user.is_moderator) %}(<a href="{{ user_url }}">{{ torrent.user.username }}</a>){% endif %}
{%- endif -%} {%- endif -%}
{%- if g.user and g.user.is_superadmin and torrent.uploader_ip -%} {% if g.user and g.user.is_superadmin and torrent.uploader_ip %}
({{ torrent.uploader_ip_string }}) ({{ torrent.uploader_ip_string }})
{%- endif -%} {% endif %}
</div> </div>
<div class="col-md-1">Seeders:</div> <div class="col-md-1">Seeders:</div>