-
Notifications
You must be signed in to change notification settings - Fork 348
[ENG-8064] Add New Notifications Data Model (Refactor Notifications Phase 2) #11151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
fb6086b
53b89ac
46b6944
dcdbdc7
68b0494
d65288e
9501714
8c6785a
3d80365
2e98358
38d7caa
ddd78d4
c89399f
bf99451
1781656
75d6f45
9e8bd85
b89846f
8e9126a
61a072f
5a8f453
df19159
ddd1cbb
c1c12bd
7c79222
e04d901
b0d0521
d77eed2
74f42bf
6eacd4d
59c5c2f
3c6dfa8
24c503b
94734fd
51df115
5ec04a0
f281e99
dbf4815
ebffbe4
795a7e6
a90a234
8421403
f9d4249
4c2d145
8d9a26f
7ccc8fb
c418021
57ba198
8745da4
c635beb
681a960
9aed0ad
bb1d1f5
519b710
4c50c6c
e228bd4
8bbe32f
40db424
496fc23
a73fb3a
466685a
a4e1fab
96db17a
5993dad
e7319cd
e2d70b1
5c6c61e
5ef1089
a6cc270
9686ae4
7fef010
21a54f4
f624258
263b952
93f9544
725d79d
fd85623
0f793a9
e7a8e3c
eae2207
fcce6d4
d2dd171
c92ca40
04a91be
6fc1923
229e08b
839af9a
efee288
bcb085d
7c8c7dd
c8c73f0
a1fb86d
5e817c8
51c416b
d2e4925
68b68ac
9658544
f9043b6
a2dd86a
46e8726
18e6e89
5a0d535
944692a
13d22f7
d9d0d0b
95bea2d
b87fa3f
aecc2ed
0776c2a
2939b71
1901d84
baea6eb
208d0ba
8bb9287
873f28d
9cac232
3fed9a4
dbe1f2f
980a986
0f43255
57d7a1a
7c41d2b
877cccb
9ffac6f
95e749d
f512919
cc0689e
679ee8d
f1d560d
de372a2
6dda64c
0e5d22a
0304ab5
05e692c
6178df1
c4c2649
07af650
ce48563
f8245d3
547aaad
a0f238b
6038ce2
eb4452b
72b7280
7f2066f
bc54d93
1f237f5
6fb6e7f
aeba2aa
14e26f3
c836a71
62918d2
0e73a2a
5591ea2
ea2503a
64ff3b0
a243f12
244b54f
abf316d
04268ba
c977eaa
b9caab4
a0f1aa5
0cd2fab
872bafe
1983847
5089376
01690b1
54f0999
b981312
1d55350
7a8e401
1c43a13
b643b79
30351cd
6b90076
e460497
7ba77c1
7ff55b2
cceab95
36db21e
68cf978
6799824
c0aa54d
dc24645
a98d958
b241b26
05aad5e
282defc
499d823
c646a43
d3c238c
8937680
5109912
de56134
7981aaf
bf9a444
f985d70
0a46af1
698ce5d
6816040
6733701
b8fdc80
89dc4ed
1f5adb4
c88a2da
80ab307
b7102b0
ab02fa7
114c130
6244b56
9124543
860430b
02d0b13
335eafd
da3d15a
9b9a9de
f9bd245
eb33db2
7d082a4
c274041
c0b1314
ff7010d
b24de31
1ae1a92
9e898a0
bd15318
f46eb8a
d03d5fa
02b7adf
200fcf8
e8f7e1f
efc3a81
bc0ec38
287ae30
f9003e8
566ca6a
a28feef
33d6fda
e2dcfe5
ee98f7f
4f988c9
27d4ec4
76ae430
ea5839c
9e638ef
13fc874
2f2d281
26a8c28
d9ca75f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,9 @@ | |
from addons.boa.boa_error_code import BoaErrorCode | ||
from framework import sentry | ||
from framework.celery_tasks import app as celery_app | ||
from osf.models import OSFUser | ||
from osf.models import OSFUser, NotificationType | ||
from osf.utils.fields import ensure_str, ensure_bytes | ||
from website import settings as osf_settings | ||
from website.mails import send_mail, ADDONS_BOA_JOB_COMPLETE, ADDONS_BOA_JOB_FAILURE | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
@@ -184,18 +183,19 @@ async def submit_to_boa_async(host, username, password, user_guid, project_guid, | |
|
||
logger.info('Successfully uploaded query output to OSF.') | ||
logger.debug('Task ends <<<<<<<<') | ||
await sync_to_async(send_mail)( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it was necessary for this to be async |
||
to_addr=user.username, | ||
mail=ADDONS_BOA_JOB_COMPLETE, | ||
fullname=user.fullname, | ||
query_file_name=query_file_name, | ||
query_file_full_path=file_full_path, | ||
output_file_name=output_file_name, | ||
job_id=boa_job.id, | ||
project_url=project_url, | ||
boa_job_list_url=boa_settings.BOA_JOB_LIST_URL, | ||
boa_support_email=boa_settings.BOA_SUPPORT_EMAIL, | ||
osf_support_email=osf_settings.OSF_SUPPORT_EMAIL, | ||
NotificationType.Type.ADDONS_BOA_JOB_COMPLETE.instance.emit( | ||
user=user, | ||
event_context={ | ||
'fullname': user.fullname, | ||
'query_file_name': query_file_name, | ||
'query_file_full_path': file_full_path, | ||
'output_file_name': output_file_name, | ||
'job_id': boa_job.id, | ||
'project_url': project_url, | ||
'boa_job_list_url': boa_settings.BOA_JOB_LIST_URL, | ||
'boa_support_email': boa_settings.BOA_SUPPORT_EMAIL, | ||
'osf_support_email': osf_settings.OSF_SUPPORT_EMAIL, | ||
} | ||
) | ||
return BoaErrorCode.NO_ERROR | ||
|
||
|
@@ -209,22 +209,24 @@ def handle_boa_error(message, code, username, fullname, project_url, query_file_ | |
sentry.log_message(message, skip_session=True) | ||
except Exception: | ||
pass | ||
send_mail( | ||
to_addr=username, | ||
mail=ADDONS_BOA_JOB_FAILURE, | ||
fullname=fullname, | ||
code=code, | ||
message=message, | ||
query_file_name=query_file_name, | ||
file_size=file_size, | ||
max_file_size=boa_settings.MAX_SUBMISSION_SIZE, | ||
query_file_full_path=query_file_full_path, | ||
output_file_name=output_file_name, | ||
job_id=job_id, | ||
max_job_wait_hours=boa_settings.MAX_JOB_WAITING_TIME / 3600, | ||
project_url=project_url, | ||
boa_job_list_url=boa_settings.BOA_JOB_LIST_URL, | ||
boa_support_email=boa_settings.BOA_SUPPORT_EMAIL, | ||
osf_support_email=osf_settings.OSF_SUPPORT_EMAIL, | ||
NotificationType.Type.ADDONS_BOA_JOB_FAILURE.instance.emit( | ||
destination_address=username, | ||
event_context={ | ||
'user_fullname': fullname, | ||
'code': code, | ||
'query_file_name': query_file_name, | ||
'file_size': file_size, | ||
'message': message, | ||
'max_file_size': boa_settings.MAX_SUBMISSION_SIZE, | ||
'query_file_full_path': query_file_full_path, | ||
'output_file_name': output_file_name, | ||
'job_id': job_id, | ||
'max_job_wait_hours': boa_settings.MAX_JOB_WAITING_TIME / 3600, | ||
'project_url': project_url, | ||
'boa_job_list_url': boa_settings.BOA_JOB_LIST_URL, | ||
'boa_support_email': boa_settings.BOA_SUPPORT_EMAIL, | ||
'osf_support_email': osf_settings.OSF_SUPPORT_EMAIL, | ||
|
||
} | ||
) | ||
return code |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
from django.contrib.auth import login, REDIRECT_FIELD_NAME, authenticate, logout | ||
|
||
from osf.models.user import OSFUser | ||
from osf.models import AdminProfile, AbstractProvider | ||
from osf.models import AdminProfile | ||
from admin.common_auth.forms import LoginForm, UserRegistrationForm, DeskUserForm | ||
|
||
|
||
|
@@ -69,16 +69,6 @@ def form_valid(self, form): | |
|
||
# create AdminProfile for this new user | ||
profile, created = AdminProfile.objects.get_or_create(user=osf_user) | ||
|
||
for group in form.cleaned_data.get('group_perms'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Johnetordoff Should get done on demand now |
||
osf_user.groups.add(group) | ||
split = group.name.split('_') | ||
group_type = split[0] | ||
if group_type == 'reviews': | ||
provider_id = split[2] | ||
provider = AbstractProvider.objects.get(id=provider_id) | ||
provider.notification_subscriptions.get(event_name='new_pending_submissions').add_user_to_subscription(osf_user, 'email_transactional') | ||
|
||
osf_user.save() | ||
|
||
if created: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
from admin.base.utils import change_embargo_date | ||
from admin.base.views import GuidView | ||
from admin.base.forms import GuidForm | ||
from admin.notifications.views import detect_duplicate_notifications, delete_selected_notifications | ||
from admin.notifications.views import delete_selected_notifications | ||
|
||
from api.share.utils import update_share | ||
from api.caching.tasks import update_storage_usage_cache | ||
|
@@ -100,7 +100,6 @@ def get_context_data(self, **kwargs): | |
context = super().get_context_data(**kwargs) | ||
node = self.get_object() | ||
|
||
detailed_duplicates = detect_duplicate_notifications(node_id=node.id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't have duplicate subscriptions, so no reason to detect, |
||
children = node.get_nodes(is_node_link=False) | ||
# Annotate guid because django templates prohibit accessing attributes that start with underscores | ||
children = AbstractNode.objects.filter( | ||
|
@@ -111,7 +110,6 @@ def get_context_data(self, **kwargs): | |
'STORAGE_LIMITS': settings.StorageLimits, | ||
'node': node, | ||
'children': children, | ||
'duplicates': detailed_duplicates | ||
}) | ||
|
||
return context | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice
event_type
is gone as that was always derived from the payload anyway, cleans up the logic a lot.