-
Notifications
You must be signed in to change notification settings - Fork 938
/
history.html
133 lines (120 loc) · 6.86 KB
/
history.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#}
{% extends "manage_team_base.html" %}
{% import "warehouse:templates/includes/pagination.html" as pagination %}
{% set active_tab = 'history' %}
{% block title %}{% trans source_name=team.name %}'{{ source_name }}' security history{% endtrans %}{% endblock %}
{% block main %}
<h2>{% trans %}Security history{% endtrans %}</h2>
<p>{% trans %}Each time you (or your collaborators) perform a security action related to this team, the action is recorded and displayed here.{% endtrans %}</p>
{% macro event_summary(event) -%}
{# Keep in sync with: warehouse/events/tags.py #}
{# Display action for team events #}
{% if event.tag == EventTag.Team.TeamCreate %}
<strong>{% trans team_name=event.additional.team_name %}{{ team_name }} team created{% endtrans %}</strong>
{% elif event.tag == EventTag.Team.TeamDelete %}
<strong>{% trans team_name=event.additional.team_name %}{{ team_name }} team deleted{% endtrans %}</strong>
{% elif event.tag == EventTag.Team.TeamRename %}
<strong>{% trans team_name=event.additional.team_name, previous_team_name=event.additional.previous_team_name %}{{ previous_team_name }} team renamed to {{ team_name }}{% endtrans %}</strong>
{# Display action for team project role events #}
{% elif event.tag == EventTag.Team.TeamProjectRoleAdd %}
<strong>
{% trans team_name=event.additional.team_name, role_name=event.additional.role_name|lower, href=request.route_path('packaging.project', name=event.additional.project_name|canonicalize_name), project_name=event.additional.project_name %}{{ team_name }} team added as project {{ role_name }} for <a href="{{ href }}">{{ project_name }}</a>{% endtrans %}
</strong>
{% elif event.tag == EventTag.Team.TeamProjectRoleRemove %}
<strong>
{% trans team_name=event.additional.team_name, role_name=event.additional.role_name|lower, href=request.route_path('packaging.project', name=event.additional.project_name|canonicalize_name), project_name=event.additional.project_name %}{{ team_name }} team removed as project {{ role_name }} for <a href="{{ href }}">{{ project_name }}</a>{% endtrans %}
</strong>
{% elif event.tag == EventTag.Team.TeamProjectRoleChange %}
<strong>
{% trans team_name=event.additional.team_name, role_name=event.additional.role_name|lower, href=request.route_path('packaging.project', name=event.additional.project_name|canonicalize_name), project_name=event.additional.project_name %}{{ team_name }} team changed to project {{ role_name }} for <a href="{{ href }}">{{ project_name }}</a>{% endtrans %}
</strong>
{# Display action for team role events #}
{% elif event.tag == EventTag.Team.TeamRoleAdd %}
{% set target_user = get_user(event.additional.target_user_id).username %}
<strong>
{% trans href=request.route_path('accounts.profile', username=target_user), username=target_user, team_name=event.additional.team_name %}<a href="{{ href }}">{{ username }}</a> added to {{ team_name }} team{% endtrans %}
</strong>
{% elif event.tag == EventTag.Team.TeamRoleRemove %}
<strong>
{% trans href=request.route_path('accounts.profile', username=target_user), username=target_user, team_name=event.additional.team_name %}<a href="{{ href }}">{{ username }}</a> removed from {{ team_name }} team{% endtrans %}
</strong>
{% else %}
<strong>{{ event.tag }}</strong>
{% endif %}
{# Display acting user for team events #}
{% if event.tag.endswith(":create") %}
{% set created_by = get_user(event.additional.created_by_user_id).username %}
<small>
{% trans %}Created by:{% endtrans %} <a href="{{ request.route_path('accounts.profile', username=created_by) }}">{{ created_by }}</a>
</small>
{% elif event.tag.endswith(":delete") %}
{% set deleted_by = get_user(event.additional.deleted_by_user_id).username %}
<small>
{% trans %}Deleted by:{% endtrans %} <a href="{{ request.route_path('accounts.profile', username=deleted_by) }}">{{ deleted_by }}</a>
</small>
{% elif event.tag.endswith(":rename") %}
{% set renamed_by = get_user(event.additional.renamed_by_user_id).username %}
<small>
{% trans %}Renamed by:{% endtrans %} <a href="{{ request.route_path('accounts.profile', username=renamed_by) }}">{{ renamed_by }}</a>
</small>
{# Display submitting user for role events #}
{% elif event.tag.endswith(":add") %}
{% set submitted_by = get_user(event.additional.submitted_by_user_id).username %}
<small>
{% trans %}Added by:{% endtrans %} <a href="{{ request.route_path('accounts.profile', username=submitted_by) }}">{{ submitted_by }}</a>
</small>
{% elif event.tag.endswith(":remove") %}
{% set submitted_by = get_user(event.additional.submitted_by_user_id).username %}
<small>
{% trans %}Removed by:{% endtrans %} <a href="{{ request.route_path('accounts.profile', username=submitted_by) }}">{{ submitted_by }}</a>
</small>
{% elif event.tag.endswith(":change") %}
{% set submitted_by = get_user(event.additional.submitted_by_user_id).username %}
<small>
{% trans %}Changed by:{% endtrans %} <a href="{{ request.route_path('accounts.profile', username=submitted_by) }}">{{ submitted_by }}</a>
</small>
{% endif %}
{%- endmacro %}
{% if events %}
<table class="table table--security-logs">
<caption class="sr-only">{% trans source_name=team.name %}Security history for {{ source_name }}{% endtrans %}</caption>
<thead>
<tr>
<th scope="col">{% trans %}Event{% endtrans %}</th>
<th scope="col">{% trans %}Time{% endtrans %}</th>
<th scope="col">{% trans %}Additional Info{% endtrans %}</th>
</tr>
</thead>
<tbody>
{% for event in events %}
<tr>
<td>{{ event_summary(event) }}</td>
<td>
<span class="table__mobile-label">{% trans %}Time{% endtrans %}</span>
{{ humanize(event.time, time="true") }}
</td>
<td>
<span class="table__mobile-label">{% trans %}Location info{% endtrans %}</span>
{{ "Redacted" if event.additional.redact_ip else event.location_info }}<br>
<span class="table__mobile-label">{% trans %}Device Info{% endtrans %}</span>
{{ event.user_agent_info }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{{ pagination.paginate(events) }}
{% endif %}
{% endblock %}