Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 44 additions & 20 deletions readthedocsext/theme/templates/projects/partials/header.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load blocktrans trans from i18n %}
{% load is_admin from privacy_tags %}
{% load is_admin admins from privacy_tags %}
{% load gravatar_url from gravatar %}
{% load get_spam_score readthedocs_language_name readthedocs_language_name_local from ext_theme_tags %}

Expand Down Expand Up @@ -193,35 +193,59 @@
</div>
</div>

<div class="ui mini modal" data-modal-id="project-debug">
<div class="header">{% trans "Debug information" %}</div>
{% comment %}
{% if user.is_staff %}
<div class="ui mini modal" data-modal-id="project-debug">
<div class="header">{% trans "Debug information" %}</div>
{% comment %}
Show spam information on community instance.
Allows us to quickly understand what's the spam score,
and also know what rules are matching this project.
{% endcomment %}
<div class="content">
{% if not USE_ORGANIZATIONS %}
<h3>{% trans "Spam" %}</h3>
<div class="ui sub header">{% trans "Spam score" %}</div>
<span>{{ project|get_spam_score }}</span>
{% if project.spam_rules.exists %}
<div class="ui sub header">{% trans "Spam matching rules" %}</div>
{% endcomment %}
<div class="content">
<h3>{% trans "Impersonate" %}</h3>
<div class="ui sub header">{% trans "Project maintainer" %}</div>
<div class="ui vertical list">
{% for user in project|admins %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To @stsewd point, we really only need one here. If there is a case for more than one, it seems reasonable to slice down to several results. There are projects/orgs with dozens of users.

You could also just link to the admin view of the filtered list of all org owners or project owners instead of duplicating this information in the application.

<div class="item">
<a href="{{ ADMIN_URL|cut:"/admin" }}/impersonate/{{ user.pk }}/" target="_blank">{{ user.username }}</a>
</div>
Comment on lines +209 to +211
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to nest these elements, links can be items too:

Suggested change
<div class="item">
<a href="{{ ADMIN_URL|cut:"/admin" }}/impersonate/{{ user.pk }}/" target="_blank">{{ user.username }}</a>
</div>
<a class="item" href="{{ ADMIN_URL|cut:"/admin" }}/impersonate/{{ user.pk }}/" target="_blank">{{ user.username }}</a>

{% endfor %}

</div>

{% if USE_ORGANIZATIONS %}
<div class="ui sub header">{% trans "Organization owner" %}</div>
<div class="ui vertical list">
{% for rule in project.spam_rules.all %}
{% for owner in organization|admins %}
<div class="item">
<a href="{{ ADMIN_URL }}/spamfighting/spamrule/{{ rule.pk }}/change/"
target="_blank">{{ rule.spam_rule_type|cut:"readthedocsext.spamfighting.rules." }}</a>
<a href="{{ ADMIN_URL|cut:"/admin" }}/impersonate/{{ owner.pk }}/" target="_blank">{{ owner.username }}</a>
</div>
{% endfor %}
</div>
{% endif %}
{% endif %}
</div>
<div class="actions">
<a href="#" class="ui negative button">{% trans "Close" %}</a>

{% if not USE_ORGANIZATIONS %}
<h3>{% trans "Spam" %}</h3>
<div class="ui sub header">{% trans "Spam score" %}</div>
<span>{{ project|get_spam_score }}</span>
{% if project.spam_rules.exists %}
<div class="ui sub header">{% trans "Spam matching rules" %}</div>
<div class="ui vertical list">
{% for rule in project.spam_rules.all %}
<div class="item">
<a href="{{ ADMIN_URL }}/spamfighting/spamrule/{{ rule.pk }}/change/"
target="_blank">{{ rule.spam_rule_type|cut:"readthedocsext.spamfighting.rules." }}</a>
</div>
{% endfor %}
</div>
{% endif %}
{% endif %}
</div>
<div class="actions">
<a href="#" class="ui negative button">{% trans "Close" %}</a>
</div>
</div>
</div>
{% endif %}
{% endblock project_header_navigation %}

{% endblock project_header %}