We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c99de36 commit 61b9f19Copy full SHA for 61b9f19
readthedocs/core/templatetags/readthedocs/__init__.py
readthedocs/core/templatetags/readthedocs/socialaccounts.py
@@ -0,0 +1,19 @@
1
+from allauth.socialaccount.adapter import get_adapter
2
+from django import forms, template
3
+
4
+register = template.Library()
5
6
7
+@register.filter
8
+def can_be_disconnected(account):
9
+ """
10
+ Check if a social account can be disconnected.
11
12
+ This is used to disable the disconnect button for certain social accounts.
13
14
+ adapter = get_adapter()
15
+ try:
16
+ adapter.validate_disconnect(account=account, accounts=[])
17
+ return True
18
+ except forms.ValidationError:
19
+ return False
0 commit comments