mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
patch social-connections into settings
This commit is contained in:
parent
3eeb6e161d
commit
f997e67ea2
@ -37,7 +37,7 @@ from rest_framework.documentation import include_docs_urls
|
||||
|
||||
from .views import auth_request
|
||||
from .views import IndexView, SearchView, DatabaseStatsView
|
||||
from .views import SettingsView, EditUserView, SetPasswordView, CustomEmailView
|
||||
from .views import SettingsView, EditUserView, SetPasswordView, CustomEmailView, CustomConnectionsView
|
||||
from .views import CurrencyRefreshView
|
||||
from .views import AppearanceSelectView, SettingCategorySelectView
|
||||
from .views import DynamicJsView
|
||||
@ -164,6 +164,7 @@ urlpatterns = [
|
||||
# Single Sign On / allauth
|
||||
# overrides of urlpatterns
|
||||
url(r'^accounts/email/', CustomEmailView.as_view(), name='account_email'),
|
||||
url(r'^accounts/social/connections/', CustomConnectionsView.as_view(), name='socialaccount_connections'),
|
||||
url(r'^accounts/', include('allauth.urls')), # included urlpatterns
|
||||
]
|
||||
|
||||
|
@ -25,8 +25,10 @@ from django.views.generic.base import RedirectView, TemplateView
|
||||
|
||||
from djmoney.contrib.exchange.models import ExchangeBackend, Rate
|
||||
from allauth.account.forms import AddEmailForm
|
||||
from allauth.socialaccount.forms import DisconnectForm
|
||||
from allauth.account.models import EmailAddress
|
||||
from allauth.account.views import EmailView
|
||||
from allauth.socialaccount.views import ConnectionsView
|
||||
|
||||
from common.settings import currency_code_default, currency_codes
|
||||
|
||||
@ -818,6 +820,10 @@ class SettingsView(TemplateView):
|
||||
ctx['add_email_form'] = AddEmailForm
|
||||
ctx["can_add_email"] = EmailAddress.objects.can_add_email(self.request.user)
|
||||
|
||||
# Form and context for allauth social-accounts
|
||||
ctx["request"] = self.request
|
||||
ctx['social_form'] = DisconnectForm(request=self.request)
|
||||
|
||||
return ctx
|
||||
|
||||
|
||||
@ -832,6 +838,17 @@ class CustomEmailView(LoginRequiredMixin, EmailView):
|
||||
return HttpResponseRedirect(self.success_url)
|
||||
|
||||
|
||||
class CustomConnectionsView(LoginRequiredMixin, ConnectionsView):
|
||||
"""
|
||||
Override of allauths ConnectionsView to always show the settings but leave the functions allow
|
||||
"""
|
||||
success_url = reverse_lazy("settings")
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
# always redirect to settings
|
||||
return HttpResponseRedirect(self.success_url)
|
||||
|
||||
|
||||
class CurrencyRefreshView(RedirectView):
|
||||
"""
|
||||
POST endpoint to refresh / update exchange rates
|
||||
|
@ -102,7 +102,7 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{% if form.accounts %}
|
||||
{% if social_form.accounts %}
|
||||
<p>{% blocktrans %}You can sign in to your account using any of the following third party accounts:{% endblocktrans %}</p>
|
||||
|
||||
|
||||
@ -110,11 +110,11 @@
|
||||
{% csrf_token %}
|
||||
|
||||
<fieldset>
|
||||
{% if form.non_field_errors %}
|
||||
<div id="errorMsg">{{ form.non_field_errors }}</div>
|
||||
{% if social_form.non_field_errors %}
|
||||
<div id="errorMsg">{{ social_form.non_field_errors }}</div>
|
||||
{% endif %}
|
||||
|
||||
{% for base_account in form.accounts %}
|
||||
{% for base_account in social_form.accounts %}
|
||||
{% with base_account.get_provider_account as account %}
|
||||
<div>
|
||||
<label for="id_account_{{ base_account.id }}">
|
||||
|
Loading…
Reference in New Issue
Block a user