Skip to content

Commit

Permalink
#829 povabila v klub, prošnje za članstvo v klubu (#166)
Browse files Browse the repository at this point in the history
* added request config

* added padding to modal window

* handle update for new pk

* added component and function to public api

* replaced system notification with emailnotification
  • Loading branch information
KlemenSpruk authored Nov 6, 2023
1 parent 851d5d3 commit 0c39ac3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions django_project_base/account/rest/invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions django_project_base/account/rest/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from typing import Any, Dict

from django.conf import settings
Expand All @@ -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


Expand All @@ -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')} "
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion django_project_base/management/commands/confirm_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions vue/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand All @@ -42,6 +45,7 @@ export const componentsConfig: { [key: string]: Component } = {
LoginDialog,
NotificationsEditor,
ProjectSettings,
ProfileSearch,
};

type AppData = Object;
Expand Down
3 changes: 2 additions & 1 deletion vue/components/profile-search.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { apiClient, gettext } from '@velis/dynamicforms';
import { AxiosRequestConfig } from 'axios';
import { computed, ref } from 'vue';
import { Ref } from 'vue/dist/vue';
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down Expand Up @@ -31,7 +32,7 @@ const selectOptions = computed(() => options.value);
function asyncSearch(query: string) {
searching.value = true;
apiClient.get(`${searchUrl}?search=${query}`).then((response) => {
apiClient.get(`${searchUrl}?search=${query}`, { showProgress: false } as AxiosRequestConfig).then((response) => {
options.value = response.data;
searching.value = false;
});
Expand Down
2 changes: 1 addition & 1 deletion vue/profile-search-add-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function showAddProfileModal(addCallback: (profile: UserDataJSON | undefin
// @ts-ignore
ProfileSearch,
{ onSelected: selected, searchUrl },
)]),
), h('div', { style: 'padding-bottom: 4em;' })]),
],
new FilteredActions({
cancel: new Action({
Expand Down

0 comments on commit 0c39ac3

Please sign in to comment.