diff --git a/django_project_base/account/rest/invite.py b/django_project_base/account/rest/invite.py index bf80468a..76bfc952 100644 --- a/django_project_base/account/rest/invite.py +++ b/django_project_base/account/rest/invite.py @@ -106,7 +106,7 @@ def new_object(self: ModelViewSet): return new_object @transaction.atomic - def create(self, request, *args, **kwargs): + def update(self, request, *args, **kwargs): self.request.data["project"] = self.request.selected_project.pk self.request.data["invited_by"] = self.request.user.userprofile created = super().create(request, *args, **kwargs) @@ -139,7 +139,7 @@ def create(self, request, *args, **kwargs): return created @transaction.atomic - def update(self, request, *args, **kwargs): + def create(self, request, *args, **kwargs): raise InviteActionNotImplementedException @transaction.atomic diff --git a/django_project_base/account/rest/profile.py b/django_project_base/account/rest/profile.py index c5ef7c0b..e0cf2e59 100644 --- a/django_project_base/account/rest/profile.py +++ b/django_project_base/account/rest/profile.py @@ -39,7 +39,7 @@ from django_project_base.base.event import UserRegisteredEvent from django_project_base.constants import NOTIFY_NEW_USER_SETTING_NAME from django_project_base.notifications.email_notification import ( - SystemEMailNotification, + EMailNotification, SystemEMailNotificationWithListOfEmails, ) from django_project_base.notifications.models import DjangoProjectBaseMessage @@ -604,7 +604,7 @@ def create(self, request, *args, **kwargs): .first() ) and sett.python_value: recipients = [response.data[get_pk_name(get_user_model())]] - SystemEMailNotification( + EMailNotification( message=DjangoProjectBaseMessage( subject=_("Your account was created for you"), body=render_to_string( @@ -616,8 +616,10 @@ def create(self, request, *args, **kwargs): footer="", content_type=DjangoProjectBaseMessage.HTML, ), + raw_recipents=recipients, project=project.slug, recipients=recipients, + delay=int(datetime.datetime.now().timestamp()), user=self.request.user.pk, ).send() diff --git a/django_project_base/account/service/reset_password_email_service.py b/django_project_base/account/service/reset_password_email_service.py index 871601ad..71e6acbc 100644 --- a/django_project_base/account/service/reset_password_email_service.py +++ b/django_project_base/account/service/reset_password_email_service.py @@ -1,3 +1,4 @@ +import datetime from typing import Any, Dict from django.conf import settings @@ -12,7 +13,7 @@ from rest_registration.utils.users import get_user_verification_id from django_project_base.account.constants import RESET_USER_PASSWORD_VERIFICATION_CODE -from django_project_base.notifications.email_notification import SystemEMailNotification +from django_project_base.notifications.email_notification import EMailNotification from django_project_base.notifications.models import DjangoProjectBaseMessage @@ -30,7 +31,7 @@ def send_reset_password_verification_email(request: Request, user, send=False) - code = get_random_string(length=6) cache.set(code_ck, code, timeout=settings.CONFIRMATION_CODE_TIMEOUT) - SystemEMailNotification( + EMailNotification( message=DjangoProjectBaseMessage( subject=f"{__('Password recovery for')} {request.META['HTTP_HOST']}", body=f"{__('You or someone acting as you requested a password reset for your account at')} " @@ -41,6 +42,9 @@ def send_reset_password_verification_email(request: Request, user, send=False) - footer="", content_type=DjangoProjectBaseMessage.PLAIN_TEXT, ), + raw_recipents=[user.pk], + project=request.selected_project.slug, + delay=int(datetime.datetime.now().timestamp()), recipients=[user.pk], user=request.user.pk, ).send() diff --git a/django_project_base/management/commands/confirm_setting.py b/django_project_base/management/commands/confirm_setting.py index 653201d6..ba5e2e67 100644 --- a/django_project_base/management/commands/confirm_setting.py +++ b/django_project_base/management/commands/confirm_setting.py @@ -32,7 +32,7 @@ def handle(self, *args, **options): footer="", content_type=DjangoProjectBaseMessage.PLAIN_TEXT, ), - recipients=[], # TODO: find project owner and send + recipients=[], # TODO: find project owner and send, when project owner is found use EmailNotification user=None, # TODO: find project owner and send -> add .send() ) return "ok" diff --git a/vue/apps.ts b/vue/apps.ts index 69a468ac..8fe6d117 100644 --- a/vue/apps.ts +++ b/vue/apps.ts @@ -13,6 +13,7 @@ import BrowserCheck from './components/browser-check.vue'; import CookieNotice from './components/cookie-notice.vue'; import AppNotification from './components/notification.vue'; import NotificationsEditor from './components/notifications-editor.vue'; +import ProfileSearch from './components/profile-search.vue'; import ProjectSettings from './components/project-settings.vue'; import TitleBar from './components/titlebar.vue'; import LoginDialog from './components/user-session/login-dialog.vue'; @@ -29,6 +30,8 @@ export { default as useLoginDialog } from './components/user-session/use-login-d export { showNotification, showGeneralErrorNotification, showMaintenanceNotification } from './notifications'; +export { default as showAddProfileModal } from './profile-search-add-user'; + export const componentsConfig: { [key: string]: Component } = { TitleBar, Breadcrumbs, @@ -42,6 +45,7 @@ export const componentsConfig: { [key: string]: Component } = { LoginDialog, NotificationsEditor, ProjectSettings, + ProfileSearch, }; type AppData = Object; diff --git a/vue/components/profile-search.vue b/vue/components/profile-search.vue index 675356af..fdb5c23f 100644 --- a/vue/components/profile-search.vue +++ b/vue/components/profile-search.vue @@ -1,6 +1,7 @@