Skip to content

Commit

Permalink
pr fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KlemenSpruk committed Nov 21, 2023
1 parent 64178e6 commit 9e66bec
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 40 deletions.
3 changes: 3 additions & 0 deletions django_project_base/celery/background_tasks/beat_task.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime

from django import db
from django.core.cache import cache

from django_project_base.celery.background_tasks.base_task import BaseTask
Expand Down Expand Up @@ -39,6 +40,7 @@ def run(self):
notification.sender = notification.extra_data["sender"]
SendNotificationService(settings=self.settings).make_send(notification, {}, resend=False)
self._clear_in_progress_status()
db.connections.close_all()

def on_failure(self, exc, task_id, args, kwargs, einfo):
self._clear_in_progress_status()
Expand All @@ -55,6 +57,7 @@ def on_failure(self, exc, task_id, args, kwargs, einfo):
EInfo: {str(einfo)}
"""
logger.exception(msg)
db.connections.close_all()


beat_task = app.register_task(BeatTask())
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
from typing import Optional

from django import db
from django.core.cache import cache

from django_project_base.celery.background_tasks.base_task import BaseTask
Expand Down Expand Up @@ -29,6 +30,7 @@ def run(self, notification: "DjangoProjectBaseNotification", extra_data): # noq
SendNotificationService(settings=self.settings).make_send(notification=notification, extra_data=extra_data)
finally:
cache.set(LAST_MAIL_SENT_CK, time.time(), timeout=NOTIFICATION_SEND_PAUSE_SECONDS + 1)
db.connections.close_all()

def on_failure(self, exc, task_id, args, kwargs, einfo):
super().on_failure(exc=exc, task_id=task_id, args=args, kwargs=kwargs, einfo=einfo)
Expand Down
3 changes: 1 addition & 2 deletions django_project_base/celery/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class CelerySettings:
app.conf.beat_schedule = {
"scheduler": {
"task": "background_tasks.beat_task.beat_task",
# "schedule": 60,
"schedule": 10, # TODO: Change to 60
"schedule": 60,
},
}

Expand Down
2 changes: 1 addition & 1 deletion django_project_base/licensing/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LogAccessService:

def __init__(self, db: Optional[str] = None) -> None:
super().__init__()
if self.db:
if db:
self.db = db

def _user_access_user_inflow(self, user_id) -> float:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging

from django import db
from django.conf import Settings
from django.utils import timezone

Expand Down Expand Up @@ -138,5 +137,4 @@ def make_send(
],
using=db_name,
)
db.connections.close_all()
return notification
69 changes: 34 additions & 35 deletions vue/components/notifications-editor.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<script setup lang="ts">
import {
Action,
APIConsumer,
ComponentDisplay,
ConsumerLogicApi, FormConsumerOneShotApi, FormPayload, gettext,
ConsumerLogicApi, FormConsumerOneShotApi, gettext,
useActionHandler,
} from '@velis/dynamicforms';
import { onMounted, onUnmounted, ref } from 'vue';
Expand All @@ -27,7 +26,7 @@ const props = defineProps<{
type: String,
required: false,
},
licenseConsumerUrlTrailingSlash:{
licenseConsumerUrlTrailingSlash: {
type: Boolean,
required: false,
},
Expand Down Expand Up @@ -100,48 +99,49 @@ onMounted(() => {
onUnmounted(() => clearInterval(intervalCheckLicense));
// const actionSendNow = async (action:Action, payload: FormPayload): Promise<boolean> => {
// TODO: WAITING FOR ISSUE https://taiga.velis.si/project/velis74-dynamic-forms/issue/858
// console.log(Math.random(), 'actionSendNow', action, payload);
// // eslint-disable-next-line no-debugger
// debugger;
// // apiClient.post(consumerUrl + (consumerTrailingSlash ? '/' : ''), payload);
// return true;
// };
const dialogHandlers = {
actionSendNow: async (action:Action, payload: FormPayload): Promise<boolean> => {
console.log(Math.random(), 'actionSendNow', action, payload);
// eslint-disable-next-line no-debugger
// apiClient.post(consumerUrl + (consumerTrailingSlash ? '/' : ''), payload);
return true;
},
'send-now': async (action:Action, payload: FormPayload): Promise<boolean> => {
console.log(Math.random(), 'actionSendNowS', action, payload);
// eslint-disable-next-line no-debugger
// apiClient.post(consumerUrl + (consumerTrailingSlash ? '/' : ''), payload);
return true;
},
sendNow: async (action:Action, payload: FormPayload): Promise<boolean> => {
console.log(Math.random(), 'actionSendNowZ', action, payload);
// eslint-disable-next-line no-debugger
// apiClient.post(consumerUrl + (consumerTrailingSlash ? '/' : ''), payload);
return true;
},
sendnow: async (action:Action, payload: FormPayload): Promise<boolean> => {
console.log(Math.random(), 'actionSendNowZŠ', action, payload);
// eslint-disable-next-line no-debugger
// apiClient.post(consumerUrl + (consumerTrailingSlash ? '/' : ''), payload);
return true;
},
};
// const dialogHandlers = {
// actionSendNow: async (action: Action, payload: FormPayload): Promise<boolean> => {
// console.log(Math.random(), 'actionSendNow', action, payload);
// // eslint-disable-next-line no-debugger
//
// // apiClient.post(consumerUrl + (consumerTrailingSlash ? '/' : ''), payload);
// return true;
// },
// 'send-now': async (action: Action, payload: FormPayload): Promise<boolean> => {
// console.log(Math.random(), 'actionSendNowS', action, payload);
// // eslint-disable-next-line no-debugger
//
// // apiClient.post(consumerUrl + (consumerTrailingSlash ? '/' : ''), payload);
// return true;
// },
// sendNow: async (action: Action, payload: FormPayload): Promise<boolean> => {
// console.log(Math.random(), 'actionSendNowZ', action, payload);
// // eslint-disable-next-line no-debugger
//
// // apiClient.post(consumerUrl + (consumerTrailingSlash ? '/' : ''), payload);
// return true;
// },
// sendnow: async (action: Action, payload: FormPayload): Promise<boolean> => {
// console.log(Math.random(), 'actionSendNowZŠ', action, payload);
// // eslint-disable-next-line no-debugger
//
// // apiClient.post(consumerUrl + (consumerTrailingSlash ? '/' : ''), payload);
// return true;
// },
// };
const { handler } = useActionHandler();
handler
.register('send-now', dialogHandlers.actionSendNow)
.register('view-license', actionViewLicense)
// .register('send-now', dialogHandlers.actionSendNow)
.register('add-notification', actionAddNotification);
// TODO: remove linter ignores below when you know how to
Expand All @@ -154,7 +154,6 @@ handler
<APIConsumer
:consumer="notificationLogic"
:display-component="ComponentDisplay.TABLE"
:dialog-handlers="dialogHandlers"
/>
<ModalView/>
</div>
Expand Down
1 change: 1 addition & 0 deletions vue/profile-search-add-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async function showAddProfileModal(addCallback: (profile: UserDataJSON | undefin
() => [h('div', [h(
// @ts-ignore
ProfileSearch,
// @ts-ignore
{ onSelected: selected, searchUrl },
), h('div', { style: 'padding-bottom: 4em;' })]),
],
Expand Down

0 comments on commit 9e66bec

Please sign in to comment.