1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00
This commit is contained in:
Nicolas Margulies 2021-10-04 20:45:05 +02:00 committed by Yohann D'ANELLO
parent e29b42eecc
commit 633ab88b04
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
4 changed files with 22 additions and 13 deletions

View File

@ -262,8 +262,10 @@ class ProfileTrustView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
trusting=context["object"].note, trusting=context["object"].note,
trusted=context["object"].note trusted=context["object"].note
)) ))
context["widget"] = {"name": "trusted", context["widget"] = {
"attrs": { "model_pk": ContentType.objects.get_for_model(Alias).pk, "name": "trusted",
"attrs": {
"model_pk": ContentType.objects.get_for_model(Alias).pk,
"class": "autocomplete form-control", "class": "autocomplete form-control",
"id": "trusted", "id": "trusted",
"resetable": True, "resetable": True,
@ -275,7 +277,6 @@ class ProfileTrustView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
return context return context
class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
""" """
View and manage user aliases. View and manage user aliases.

View File

@ -68,7 +68,7 @@ class TrustViewSet(ReadProtectedModelViewSet):
filter_backends = [SearchFilter, DjangoFilterBackend, OrderingFilter] filter_backends = [SearchFilter, DjangoFilterBackend, OrderingFilter]
search_fields = ['$trusting__alias__name', '$trusting__alias__normalized_name', search_fields = ['$trusting__alias__name', '$trusting__alias__normalized_name',
'$trusted__alias__name', '$trusted__alias__normalized_name'] '$trusted__alias__name', '$trusted__alias__normalized_name']
filterset_fields = ['trusting', 'trusting__noteuser__user', 'trusted', 'trusted__noteuser__user',] filterset_fields = ['trusting', 'trusting__noteuser__user', 'trusted', 'trusted__noteuser__user']
ordering_fields = ['trusting', 'trusted', ] ordering_fields = ['trusting', 'trusted', ]
def get_serializer_class(self): def get_serializer_class(self):

View File

@ -244,6 +244,10 @@ class Trust(models.Model):
verbose_name_plural = _("friendships") verbose_name_plural = _("friendships")
unique_together = ("trusting", "trusted") unique_together = ("trusting", "trusted")
def __str__(self):
return _("Friendship between {trusting} and{trusted}").format(
trusting=str(self.trusting), trusted=str(self.trusted))
class Alias(models.Model): class Alias(models.Model):
""" """

View File

@ -161,11 +161,15 @@ class TrustTable(tables.Table):
show_header = False 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, delete_col = tables.TemplateColumn(
template_code=DELETE_TEMPLATE,
extra_context={"delete_trans": _('delete')}, extra_context={"delete_trans": _('delete')},
attrs={'td': {'class': lambda record: 'col-sm-1' + (' d-none' attrs={
if not PermissionBackend.check_perm(get_current_request(), 'td': {
"note.delete_trust", record) else '')}}, 'class': lambda record: 'col-sm-1'
+ (' d-none' if not PermissionBackend.check_perm(
get_current_request(), "note.delete_trust", record)
else '')}},
verbose_name=_("Delete"),) verbose_name=_("Delete"),)