|
14 | 14 |
|
15 | 15 |
|
16 | 16 | {% macro button_for_membership(community_ui) %} |
17 | | - {% set request_id_of_pending_member = get_request_id_of_pending_member(g.identity, community_ui.id) %} |
18 | | - {# None if no pending membership or invitation request #} |
19 | | - |
20 | | - {% if request_id_of_pending_member %} |
21 | | - <a href="{{ url_for('invenio_app_rdm_requests.user_dashboard_request_view', request_pid_value=request_id_of_pending_member) }}" |
22 | | - class="ui button labeled icon rel-mt-1 theme-secondary"> |
23 | | - <i class="sign-in icon" aria-hidden="true"></i> |
24 | | - {{ _("Membership discussion") }} |
25 | | - </a> |
26 | | - {% elif permissions.can_request_membership %} |
27 | | - <div |
28 | | - id="request-membership-app" |
29 | | - data-community='{{ community_ui | tojson }}' |
30 | | - class="display-inline-block" |
31 | | - > |
32 | | - </div> |
33 | | - {% else %} |
34 | | - {# show nothing #} |
| 17 | + {# Macro to display the button related to membership (request or discussion) #} |
| 18 | + |
| 19 | + {# Ths conditionals try hard to reduce the need for a DB hit #} |
| 20 | + {% if config.COMMUNITIES_ALLOW_MEMBERSHIP_REQUESTS %} |
| 21 | + {% if community_ui["access"]["member_policy"] == "open" %} |
| 22 | + {# The below permission check includes the above checks among other checks, so |
| 23 | + it was not enough on its own to prevent a large swath of cases where the DB |
| 24 | + could be hit. |
| 25 | + #} |
| 26 | + {% if permissions.can_request_membership %} |
| 27 | + <div |
| 28 | + id="request-membership-app" |
| 29 | + data-community='{{ community_ui | tojson }}' |
| 30 | + class="display-inline-block" |
| 31 | + > |
| 32 | + </div> |
| 33 | + {% else %} |
| 34 | + {% set request_id_of_pending_member = get_request_id_of_pending_member(g.identity, community_ui["id"]) %} |
| 35 | + {# None if no pending membership or invitation request #} |
| 36 | + {% if request_id_of_pending_member %} |
| 37 | + <a href="{{ url_for('invenio_app_rdm_requests.user_dashboard_request_view', request_pid_value=request_id_of_pending_member) }}" |
| 38 | + class="ui button labeled icon rel-mt-1 theme-secondary"> |
| 39 | + <i class="sign-in icon" aria-hidden="true"></i> |
| 40 | + {{ _("Membership discussion") }} |
| 41 | + </a> |
| 42 | + {% endif %} |
| 43 | + {% endif %} |
| 44 | + {% endif %} |
35 | 45 | {% endif %} |
| 46 | + |
36 | 47 | {% endmacro %} |
37 | 48 |
|
38 | 49 | {% macro community_title(community_ui) %} |
|
0 commit comments