fix report related issues
This commit is contained in:
parent
6eebfe67b8
commit
89094ff262
6 changed files with 18 additions and 7 deletions
|
@ -162,7 +162,7 @@
|
|||
<!-- <a href="#" class="follow">{% trans '关注TA' %}</a> -->
|
||||
|
||||
{% if request.user != user %}
|
||||
<a href="#" class="report">{% trans '举报用户' %}</a>
|
||||
<a href="{% url 'users:report' %}?user_id={{ user.id }}" class="report">{% trans '举报用户' %}</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
<a href="{% url 'common:home' %}">
|
||||
<img src="{% static 'img/logo.svg' %}" alt="" class="logo">
|
||||
</a>
|
||||
<input type="search" class="search-box" name="keywords" id="searchInput" required="true" placeholder="{% trans '搜索书影音,多个关键字以空格分割' %}">
|
||||
<input type="search" class="search-box" name="keywords"
|
||||
value="{% if request.GET.keywords %}{{ request.GET.keywords }}{% endif %}" id="searchInput" required="true" placeholder="{% trans '搜索书影音,多个关键字以空格分割' %}">
|
||||
<a class="nav-link" id="logoutLink" href="{% url 'users:logout' %}">{% trans '登出' %}</a>
|
||||
<a class="nav-link" href="{% url 'common:home' %}">{% trans '主页' %}</a>
|
||||
{% if request.user.is_staff %}
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
<!-- <a href="#" class="follow">{% trans '关注TA' %}</a> -->
|
||||
|
||||
{% if request.user != user %}
|
||||
<a href="{% url 'users:report' %}" class="report">{% trans '举报用户' %}</a>
|
||||
<a href="{% url 'users:report' %}?user_id={{ user.id }}" class="report">{% trans '举报用户' %}</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -14,3 +14,8 @@ class ReportForm(forms.ModelForm):
|
|||
widgets = {
|
||||
'message': forms.Textarea(attrs={'placeholder': _("详情")}),
|
||||
}
|
||||
labels = {
|
||||
'reported_user': _("举报的用户"),
|
||||
'image': _("相关证据"),
|
||||
'message': _("详情")
|
||||
}
|
|
@ -84,7 +84,7 @@
|
|||
<!-- <a href="#" class="follow">{% trans '关注TA' %}</a> -->
|
||||
|
||||
{% if request.user != user %}
|
||||
<a href="#" class="report">{% trans '举报用户' %}</a>
|
||||
<a href="{% url 'users:report' %}?user_id={{ user.id }}" class="report">{% trans '举报用户' %}</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
|
|
@ -118,7 +118,7 @@ def delete(request):
|
|||
@login_required
|
||||
def home(request, id):
|
||||
if request.method == 'GET':
|
||||
if request.GET.get('is_mastodon_id') in ['true', 'True']:
|
||||
if request.GET.get('is_mastodon_id', '').lower() == 'true':
|
||||
query_kwargs = {'mastodon_id': id}
|
||||
else:
|
||||
query_kwargs = {'pk': id}
|
||||
|
@ -309,7 +309,12 @@ def book_list(request, id, status):
|
|||
@login_required
|
||||
def report(request):
|
||||
if request.method == 'GET':
|
||||
form = ReportForm()
|
||||
user_id = request.GET.get('user_id')
|
||||
if user_id:
|
||||
user = get_object_or_404(User, pk=user_id)
|
||||
form = ReportForm(initial={'reported_user': user})
|
||||
else:
|
||||
form = ReportForm()
|
||||
return render(
|
||||
request,
|
||||
'users/report.html',
|
||||
|
|
Loading…
Add table
Reference in a new issue