def post(self, request, *args, **kwargs): self.object = self.get_object() invitation_backend().send_reminder( self.object.user, **{"domain": get_current_site(self.request), "organization": self.organization, "sender": request.user} ) return HttpResponseRedirect(self.object.get_absolute_url())
def save(self, *args, **kwargs): """ The save method should create a new OrganizationUser linking the User matching the provided email address. If not matching User is found it should kick off the registration process. It needs to create a User in order to link it to the Organization. """ try: user = get_user_model().objects.get(email__iexact=self.cleaned_data['email']) except get_user_model().MultipleObjectsReturned: raise forms.ValidationError(_("This email address has been used multiple times.")) except get_user_model().DoesNotExist: user = invitation_backend().invite_by_email( self.cleaned_data['email'], **{'domain': get_current_site(self.request), 'organization': self.organization, 'sender': self.request.user}) else: notification_backend().notify_by_email(self.cleaned_data['email'], **{'domain': get_current_site(self.request), 'organization': self.organization, 'sender': self.request.user}) return OrganizationUser.objects.create(user=user, organization=self.organization, is_admin=self.cleaned_data['is_admin'])
def save(self): """ Create the organization, then get the user, then make the owner. """ try: user = User.objects.get(email=self.cleaned_data['email']) except User.DoesNotExist: user = invitation_backend().create_invitation( self.cleaned_data['email'], **{'domain': get_current_site(self.request), 'organization': self.cleaned_data['name'], 'sender': self.request.user, 'created': True}) return create_organization(self.cleaned_data['name'], user)
def save(self, **kwargs): """ Create the organization, then get the user, then make the owner. """ is_active = True try: user = get_user_model().objects.get(email=self.cleaned_data['email']) except get_user_model().DoesNotExist: user = invitation_backend().invite_by_email( self.cleaned_data['email'], **{'domain': get_current_site(self.request), 'organization': self.cleaned_data['name'], 'sender': self.request.user, 'created': True}) is_active = False return create_organization(user, self.cleaned_data['name'], self.cleaned_data['slug'], is_active=is_active)
def save(self, *args, **kwargs): """ The save method should create a new OrganizationUser linking the User matching the provided email address. If not matching User is found it should kick off the registration process. It needs to create a User in order to link it to the Organization. """ try: user = get_user_model().objects.get(email__iexact=self.cleaned_data['email']) except get_user_model().MultipleObjectsReturned: raise forms.ValidationError(_("This email address has been used multiple times.")) except get_user_model().DoesNotExist: user = invitation_backend().invite_by_email( self.cleaned_data['email'], **{'domain': get_current_site(self.request), 'organization': self.organization}) return OrganizationUser.objects.create(user=user, organization=self.organization, is_admin=self.cleaned_data['is_admin'])
def save(self, **kwargs): """ Create the organization, then get the user, then make the owner. """ is_active = True try: user = get_user_model().objects.get(email=self.cleaned_data["email"]) except get_user_model().DoesNotExist: user = invitation_backend().invite_by_email( self.cleaned_data["email"], **{ "domain": get_current_site(self.request), "organization": self.cleaned_data["name"], "sender": self.request.user, "created": True, } ) is_active = False return create_organization(user, self.cleaned_data["name"], self.cleaned_data["slug"], is_active=is_active)
def save(self, *args, **kwargs): """ This method saves changes to the linked user model. """ # Hack in the organization field since we excluded it manually self.instance.organization = kwargs.pop('team') if self.instance.pk is None: site = Site.objects.get(pk=settings.SITE_ID) self.instance.user = invitation_backend().invite_by_email( self.cleaned_data['email'], **{ 'first_name': self.cleaned_data['first_name'], 'last_name': self.cleaned_data['last_name'], 'organization': self.instance.organization, 'domain': site }) self.instance.user.first_name = self.cleaned_data['first_name'] self.instance.user.last_name = self.cleaned_data['last_name'] self.instance.user.email = self.cleaned_data['email'] self.instance.user.save() return super(TeamMemberForm, self).save(*args, **kwargs)
def save(self, **kwargs): """ Create the organization, then get the user, then make the owner. """ is_active = True try: user = get_user_model().objects.get( email=self.cleaned_data['email']) except get_user_model().DoesNotExist: user = invitation_backend().invite_by_email( self.cleaned_data['email'], **{ 'domain': get_current_site(self.request), 'organization': self.cleaned_data['name'], 'sender': self.request.user, 'created': True }) is_active = False return create_organization(user, self.cleaned_data['name'], self.cleaned_data['slug'], is_active=is_active)
def save(self, *args, **kwargs): """ The save method should create a new OrganizationUser linking the User matching the provided email address. If not matching User is found it should kick off the registration process. It needs to create a User in order to link it to the Organization. """ try: user = User.objects.get(email=self.cleaned_data['email']) except User.MultipleObjectsReturned: raise forms.ValidationError(_("This email address has been used multiple times.")) except User.DoesNotExist: # TODO either replace the way the domain is set or send the request # so that the backend can do it... OR send a callable or use a # custom function... user = invitation_backend().create_invitation( self.cleaned_data['email'], **{'domain': get_current_site(self.request), 'organization': self.organization}) return OrganizationUser.objects.create(user=user, organization=self.organization, is_admin=self.cleaned_data['is_admin'])
def save(self, **kwargs): """ Create the organization, then get the user, then make the owner. """ is_active = True try: user = get_user_model().objects.get( email=self.cleaned_data["email"]) except get_user_model().DoesNotExist: user = invitation_backend().invite_by_email( self.cleaned_data["email"], **{ "domain": get_current_site(self.request), "organization": self.cleaned_data["name"], "sender": self.request.user, "created": True, }) is_active = False return create_organization( user, self.cleaned_data["name"], self.cleaned_data["slug"], is_active=is_active, )
def post(self, request, *args, **kwargs): self.object = self.get_object() invitation_backend().send_reminder(self.object.user, **{'domain': get_current_site(self.request), 'organization': self.organization, 'sender': request.user}) return redirect(self.object)
def test_backend_definition(self): from organizations.backends import invitation_backend self.assertTrue(isinstance(invitation_backend(), InvitationBackend))
from django.conf.urls import include, url from django.contrib import admin from organizations.backends import invitation_backend, registration_backend admin.autodiscover() urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^organizations/', include('organizations.urls')), url(r'^invite/', include(invitation_backend().get_urls())), url(r'^register/', include(registration_backend().get_urls())), ]
from django.conf.urls import patterns, include, url from django.contrib import admin from organizations.backends import invitation_backend, registration_backend admin.autodiscover() urlpatterns = patterns( "", url(r"^admin/", include(admin.site.urls)), url(r"^organizations/", include("organizations.urls")), url(r"^invite/", include(invitation_backend().get_urls())), url(r"^register/", include(registration_backend().get_urls())), )
from django.conf.urls import include, url from django.contrib import admin from organizations.backends import invitation_backend, registration_backend admin.autodiscover() urlpatterns = [ url(r"^admin/", include(admin.site.urls)), url(r"^organizations/", include("organizations.urls")), url(r"^invite/", include(invitation_backend().get_urls())), url(r"^register/", include(registration_backend().get_urls())), ]
from django.contrib import admin from django.urls import path, include from main.views import MainView, UserViewSet from rest_framework_nested import routers from organizations.backends import invitation_backend import notifications.urls router = routers.SimpleRouter() router.register(r'users', UserViewSet) urlpatterns = [ path('admin/', admin.site.urls), path('', include(router.urls)), # path('auth/', LoginView.as_view({'post': 'create'})), path("", MainView.as_view(), name='main'), path(r'^accounts/', include('organizations.urls')), path(r'^invitations/', include(invitation_backend().get_urls())), path('^inbox/notifications/', include(notifications.urls, namespace='notifications')), ]
url(r'^workflow/$', workflow_views.list, name='core_workflow_list'), url(r'^wf/(?P<id>[-\w]+)/$', workflow_views.workflow_permalink, name='core_workflow_permalink'), url(r'^log/(?P<id>[-\w]+)/$', workflow_views.workflow_log_permalink, name='core_workflow_log_permalink'), url(r'^user/parameter/(?P<id>[-\w]+)/delete/$', preferences_views.user_parameter_delete, name='core_user_parameter_delete'), url(r'^user/parameter/(?P<id>[-\w]+)/$', preferences_views.user_parameter_detail, name='core_user_parameter_detail'), url(r'^user/parameter/$', preferences_views.user_parameter, name='core_user_parameter'), url(r'^user/activity/$', preferences_views.user_activity, name='core_user_activity'), url(r'^user/$', preferences_views.user_profile, name='core_user_profile'), url(r'^teams/add/$', preferences_views.organization_add, name='core_organization_add'), url(r'^teams/(?P<slug>[-\w]+)/parameter/(?P<id>[-\w]+)/delete/$', preferences_views.organization_parameter_delete, name='core_organization_parameter_delete'), url(r'^teams/(?P<slug>[-\w]+)/parameter/(?P<id>[-\w]+)/$', preferences_views.organization_parameter_detail, name='core_organization_parameter_detail'), url(r'^teams/(?P<slug>[-\w]+)/parameter/list/(?P<list_id>[-\w]+)/$', preferences_views.organization_parameter_list, name='core_organization_parameter_list'), url(r'^teams/(?P<slug>[-\w]+)/parameter/$', preferences_views.organization_parameter, name='core_organization_parameter'), url(r'^teams/(?P<slug>[-\w]+)/activity/$', preferences_views.organitazion_activity, name='core_organization_activity'), url(r'^teams/', include('organizations.urls')), url(r'^invitations/', include(invitation_backend().get_urls())), url(r'^chooseorg/$', base_views.chooseorg), url(r'^login/$', base_views.user_login, name='auth_login'), url(r'^logout/$', base_views.user_logout, name='auth_logout'), url(r'^orgswitcher/(?P<slug>[-\w]+)/$', base_views.orgswitcher), url(r'^$', base_views.index, name='core_index'), ### API ### url(r'^api/workers/(?P<id>[-\d]+)/$', api_views_worker.detail, name='api_worker_detail'), url(r'^api/logs/(?P<id>[-\d]+)/$', api_views_log.detail, name='api_log_detail'), ]
extra_context={"schema_url": "openapi-schema"}, ), name="swagger-ui", ), path( "api/redoc/", TemplateView.as_view( template_name="redoc.html", extra_context={"schema_url": "openapi-schema"}, ), name="redoc", ), path("api/auth/", include("rest_framework.urls")), path("api/token/", views.obtain_auth_token), # Django organizations path("invitations/", include(invitation_backend().get_urls())), path("organization/", include("organizations.urls")), # Your stuff: custom urls includes go here re_path( f"^api/{API_PREFIX}/", include(("transportation_suppliers.users.api.urls", "api_users")), ), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: # This allows the error pages to be debugged during development, just visit # these url in browser to see how these error pages look like. urlpatterns += [ path( "400/", default_views.bad_request,