~sircmpwn/lists.sr.ht

ref: 7a80ef388bb4b3774874dd95995efc49df7a654b lists.sr.ht/listssrht/templates/settings-access.html -rw-r--r-- 6.1 KiB View raw
7a80ef38Drew DeVault Filter "normal" access from settings-access.html 5 months ago
                                                                                
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{% extends "settings.html" %}
{% block title %}
<title>
  {{ owner.canonical_name }}/{{ ml.name }} settings &mdash; {{ cfg("sr.ht", "site-name") }} lists
</title>
{% endblock %}

{% macro perm_checkbox(type, perms, name, readonly=False) %}
{% if type.name not in ["none", "normal", "all"] %}
<div class="form-check form-check-inline">
  <label
    class="form-check-label"
    title="{{access_help_map[type]}}"
  >
    {% if readonly %}
      {% if type in perms %}
        {{icon('check', cls='text-success')}}
      {% else %}
        <span style="display: inline-block; min-width: 16px;">
          {{icon('times', cls='text-danger')}}
        </span>
      {% endif %}
      {{type.name}}
    {% else %}
    <input
      class="form-check-input"
      type="checkbox"
      {% if name %}
      name="perm_{{ name }}_{{ type.name }}"
      {% endif %}
      value="{{type.value}}"
      {% if readonly %}
      disabled
      {% endif %}
      {{ "checked" if type in perms }}
    > {{type.name}}
    {% endif %}
  </label>
</div>
{% endif %}
{% endmacro %}

{% block content %}
<div class="container">
  {% if not hide_global %}
  <div class="row">
    <div class="col-md-10">
      <form method="POST">
        <h3>Global permissions</h3>
        {{csrf_token()}}
        <div class="form-group {{valid.cls("list_any_access")}}">
          <p>
            These permissions allow you to control what kinds of users are able
            to do what sorts of activities on your mailing list.
          </p>
          <div class="event-list">
            <div class="event">
              <h4>Non-subscriber Permissions</h4>
              <p>
                Permissions granted to users who are not subscribed or logged
                in to a sr.ht account. Any permission granted to anonymous
                users are granted to subscribers and account holders as well,
                unless explicitly revoked from that user.
              </p>
              {% for a in access_type_list %}
              {{ perm_checkbox(a, ml.nonsubscriber_permissions , "nonsub") }}
              {% endfor %}
              {{ valid.summary("list_nonsubscriber_access") }}
            </div>
            <div class="event">
              <h4>Subscriber Permissions</h4>
              <p>
                Permissions granted to users who are subscribed to the list.
              </p>
              {% for a in access_type_list %}
              {{ perm_checkbox(a, ml.subscriber_permissions , "sub") }}
              {% endfor %}
              {{ valid.summary("list_subscriber_access") }}
            </div>
            <div class="event">
              <h4>Account Holder Permissions</h4>
              <p>
                Permissions granted to logged in holders of sr.ht accounts.
              </p>
              {% for a in access_type_list %}
              {{ perm_checkbox(a, ml.account_permissions, "account") }}
              {% endfor %}
              {{ valid.summary("list_account_access") }}
            </div>
          </div>
        </div>
        <p>The list owner (you) is always granted all permissions.</p>
        {{ valid.summary() }}
        <span class="pull-right">
          <button type="submit" class="btn btn-primary">
            Save changes {{icon("caret-right")}}
          </button>
        </span>
      </form>
    </div>
  </div>
  {% endif %}
  {% if not hide_user %}
  <div class="row">
    <div class="col-md-12">
      <h3>User permissions</h3>
      {% if any(ml.acls) %}
      <table class="table">
        <thead>
          <tr>
            <th>user</th>
            <th>granted</th>
            <th>access</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          {% for acl in ml.acls %}
          <tr>
            <td>
              {% if acl.user %}
              <a
                href="{{url_for("user.user_profile",
                  username=acl.user.username)}}"
              >~{{acl.user.username}}</a>
              {% else %}
              <a href="mailto:{{ acl.email }}">{{acl.email}}</a>
              {% endif %}
            </td>
            <td>{{ acl.created | date }}</td>
            <td>
              {% for a in access_type_list %}
              {{ perm_checkbox(a, acl.permissions, None, readonly=True) }}
              {% endfor %}
            </td>
            <td style="width: 6rem">
              <form
                method="POST"
                action="{{url_for("settings.acl_delete_POST",
                  owner_name=ml.owner.canonical_name, list_name=ml.name,
                  acl_id=acl.id)}}"
              >
                {{csrf_token()}}
                <button type="submit" class="btn btn-danger btn-fill">
                  Delete
                </button>
              </form>
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
      {% endif %}
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <form method="POST" action="{{url_for("settings.acl_POST", 
            owner_name=ml.owner.canonical_name, list_name=ml.name)}}">
        {{csrf_token()}}
        <div class="form-group">
          <label for="user">Username or email</label>
          <input
            type="text"
            class="form-control {{valid.cls("user")}}"
            id="user"
            name="user"
            placeholder="~{{ current_user.username }} or {{current_user.email}}"
            value="{{user or ""}}"
          />
          {{valid.summary("user")}}
        </div>
        <div class="event-list">
          <div class="event">
            <h4>Access grants</h4>
            <p>These will override any other permissions for this user.</p>
            {% for a in access_type_list %}
            {{ perm_checkbox(a, ListAccess.all, "acl") }}
            {% endfor %}
            {{ valid.summary("list_acl_access") }}
          </div>
        </div>
        {{ valid.summary() }}
        <span class="pull-right">
          <button type="submit" class="btn btn-primary">
            Set access {{icon("caret-right")}}
          </button>
        </span>
      </form>
    </div>
  </div>
  {% endif %}
</div>
{% endblock %}