diff --git a/apps/member/templates/member/profile_trust.html b/apps/member/templates/member/profile_trust.html index bd8d6b50..5a65462e 100644 --- a/apps/member/templates/member/profile_trust.html +++ b/apps/member/templates/member/profile_trust.html @@ -7,7 +7,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {% block profile_content %}

- {% trans "Note friendships" %} + {% trans "Add friends" %}

{% if can_create %} @@ -24,7 +24,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {% render_table trusting %}
-
+
{% blocktrans trimmed %} Adding someone as a friend enables them to initiate transactions coming from your account (while keeping your balance positive). This is @@ -33,6 +33,13 @@ SPDX-License-Identifier: GPL-3.0-or-later friends without needing additional rights among them. {% endblocktrans %}
+ +
+

+ {% trans "People trusting you" %} +

+ {% render_table trusted_by %} +
{% endblock %} {% block extrajavascript %} diff --git a/apps/member/views.py b/apps/member/views.py index 63307383..a41b0bff 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -21,7 +21,7 @@ from django_tables2.views import SingleTableView from rest_framework.authtoken.models import Token from note.models import Alias, NoteClub, NoteUser, Trust from note.models.transactions import Transaction, SpecialTransaction -from note.tables import HistoryTable, AliasTable, TrustTable +from note.tables import HistoryTable, AliasTable, TrustTable, TrustedTable from note_kfet.middlewares import _set_current_request from permission.backends import PermissionBackend from permission.models import Role @@ -258,6 +258,8 @@ class ProfileTrustView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): note = context['object'].note context["trusting"] = TrustTable( note.trusting.filter(PermissionBackend.filter_queryset(self.request, Trust, "view")).distinct().all()) + context["trusted_by"] = TrustedTable( + note.trusted.filter(PermissionBackend.filter_queryset(self.request, Trust, "view")).distinct().all()) context["can_create"] = PermissionBackend.check_perm(self.request, "note.add_trust", Trust( trusting=context["object"].note, trusted=context["object"].note diff --git a/apps/note/tables.py b/apps/note/tables.py index 1e94a39f..6c684d69 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -159,7 +159,7 @@ class TrustTable(tables.Table): template_name = 'django_tables2/bootstrap4.html' show_header = False - trusted = tables.Column(attrs={'td': {'class': 'text_center'}}) + trusted = tables.Column(attrs={'td': {'class': 'text-center'}}) delete_col = tables.TemplateColumn( template_code=DELETE_TEMPLATE, @@ -172,6 +172,19 @@ class TrustTable(tables.Table): else '')}}, verbose_name=_("Delete"),) +class TrustedTable(tables.Table): + class Meta: + attrs = { + 'class': 'table table condensed table-striped', + 'id': 'trusted_table' + } + Model = Trust + fields = ("trusting",) + template_name = "django_tables2/bootstrap4.html" + + show_header = False + trusting = tables.Column(attrs={'td': {'class': 'text-center'}}) + class AliasTable(tables.Table): class Meta: diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index 5776abab..0553f39f 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -3093,6 +3093,22 @@ "field": "", "permanent": false, "description": "Créer un crédit quelconque" + } + }, + { + "model": "permission.permission", + "pk": 198, + "fields": { + "model": [ + "note", + "trust" + ], + "query": "{\"trusted__noteuser__user\": [\"user\"]}", + "type": "view", + "mask": 1, + "field": "", + "permanent": true, + "description": "Voir ceux nous ayant pour ami, pour toujours" } }, { @@ -3132,10 +3148,11 @@ 187, 188, 189, - 190, - 191, - 195, - 196 + 190, + 191, + 195, + 196, + 198 ] } },