-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
[WIP] Notifications app #2967
[WIP] Notifications app #2967
Conversation
@@ -0,0 +1,3 @@ | |||
from django.contrib import admin |
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.
F401 'django.contrib.admin' imported but unused
@@ -0,0 +1,3 @@ | |||
from django.db import models |
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.
F401 'django.db.models' imported but unused
@@ -0,0 +1,3 @@ | |||
from django.test import TestCase |
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.
F401 'django.test.TestCase' imported but unused
@@ -0,0 +1,3 @@ | |||
from django.shortcuts import render |
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.
F401 'django.shortcuts.render' imported but unused
app/inbox/apps.py
Outdated
from django.apps import AppConfig | ||
|
||
|
||
class NotificationsConfig(AppConfig): |
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.
Mind switching this over to singular?
Codecov Report
@@ Coverage Diff @@
## master #2967 +/- ##
==========================================
- Coverage 29.8% 29.77% -0.03%
==========================================
Files 180 185 +5
Lines 13718 13848 +130
Branches 1838 1856 +18
==========================================
+ Hits 4088 4123 +35
- Misses 9492 9587 +95
Partials 138 138
Continue to review full report at Codecov.
|
@@ -138,7 +138,7 @@ | |||
|
|||
TEMPLATES = [{ | |||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |||
'DIRS': ['retail/templates/', 'external_bounties/templates/', 'dataviz/templates', 'kudos/templates'], | |||
'DIRS': ['retail/templates/', 'external_bounties/templates/', 'dataviz/templates', 'kudos/templates', 'inbox/templates'], |
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.
E501 line too long (125 > 120 characters)
@Anish-Agnihotri here is the PR to work with I will be updating it so we can work together. Ping me if anything. |
|
||
# Create your models here. | ||
|
||
class Notification(models.Model): |
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.
E302 expected 2 blank lines, found 1
app/inbox/views.py
Outdated
|
||
# Create your views here. | ||
|
||
def inbox(request, notification): |
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.
E302 expected 2 blank lines, found 1
Hey @Anish-Agnihotri any update on this? |
[WIP] Changes to backend for notifications
app/inbox/models.py
Outdated
|
||
# Create your models here. | ||
|
||
class Notification(SuperModel): |
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.
E302 expected 2 blank lines, found 1
app/inbox/views.py
Outdated
@@ -0,0 +1,49 @@ | |||
from django.contrib.staticfiles.templatetags.staticfiles import static | |||
from django.core.paginator import Paginator |
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.
F401 'django.core.paginator.Paginator' imported but unused
from django.core.paginator import Paginator | ||
from django.shortcuts import render | ||
from django.template.response import TemplateResponse | ||
from django.utils import timezone |
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.
F401 'django.utils.timezone' imported but unused
|
||
from django.http import JsonResponse, HttpResponseForbidden | ||
|
||
def notifications(request): |
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.
E302 expected 2 blank lines, found 1
app/inbox/views.py
Outdated
def notifications(request): | ||
"""Handle grants explorer.""" | ||
profile = request.user.profile if request.user.is_authenticated and request.user.profile else None | ||
limit = request.GET.get('limit', 25) |
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.
F841 local variable 'limit' is assigned to but never used
app/inbox/views.py
Outdated
"""Handle grants explorer.""" | ||
profile = request.user.profile if request.user.is_authenticated and request.user.profile else None | ||
limit = request.GET.get('limit', 25) | ||
page = request.GET.get('page', 1) |
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.
F841 local variable 'page' is assigned to but never used
app/inbox/views.py
Outdated
profile = request.user.profile if request.user.is_authenticated and request.user.profile else None | ||
limit = request.GET.get('limit', 25) | ||
page = request.GET.get('page', 1) | ||
sort = request.GET.get('sort_option', '-created_on') |
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.
F841 local variable 'sort' is assigned to but never used
|
||
return JsonResponse(params, status=200, safe=False) | ||
|
||
def inbox(request): |
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.
E302 expected 2 blank lines, found 1
@@ -0,0 +1,4 @@ | |||
from django.apps import AppConfig | |||
|
|||
class NotificationConfig(AppConfig): |
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.
E302 expected 2 blank lines, found 1
notifications.push(element); | ||
}); | ||
|
||
markAsRead(newNotifications) |
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.
Missing semicolon. (semi)
app/assets/v2/js/notifications.js
Outdated
} | ||
|
||
function markAsRead(notificationsA) { | ||
console.log(notificationsA) |
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.
Unexpected console statement. (no-console)
Missing semicolon. (semi)
|
||
function markAsRead(notificationsA) { | ||
console.log(notificationsA) | ||
var notificationRead = parseInt(sessionStorage.getItem('notificationRead')) |
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.
Missing semicolon. (semi)
var notificationRead = parseInt(sessionStorage.getItem('notificationRead')) | ||
|
||
if (notificationRead) { | ||
console.log('ping') |
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.
Unexpected console statement. (no-console)
Missing semicolon. (semi)
if (notificationRead) { | ||
console.log('ping') | ||
sessionStorage.removeItem('notificationRead'); | ||
console.log('api request readed', notificationRead); |
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.
Unexpected console statement. (no-console)
// notificationRead = parseInt(notificationRead) | ||
|
||
const resulta = notificationsA.findIndex(item => { | ||
return item.id === notificationRead |
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.
Missing semicolon. (semi)
|
||
const resulta = notificationsA.findIndex(item => { | ||
return item.id === notificationRead | ||
}) |
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.
Missing semicolon. (semi)
|
||
$(document).ready(function() { | ||
|
||
$('.notifications__box').on('click', '[data-notification]', function(e){ |
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.
Missing space before opening brace. (space-before-blocks)
|
||
$('.notifications__box').on('click', '[data-notification]', function(e){ | ||
window.sessionStorage.setItem('notificationRead', e.currentTarget.dataset.notification); | ||
}) |
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.
Missing semicolon. (semi)
window.sessionStorage.setItem('notificationRead', e.currentTarget.dataset.notification); | ||
}) | ||
|
||
}) |
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.
Missing semicolon. (semi)
Added pagination for loading notifs
Fix AttributeError in inbox.views
const container = $('.notifications__list'); | ||
|
||
function requestNotifications() { | ||
console.log(page) |
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.
Unexpected console statement. (no-console)
Missing semicolon. (semi)
|
||
$.when(getNotifications).then(function(response) { | ||
// var loadTmp = response.data.length && response.data[0].id !== notifications[0].id; | ||
var loadTmp = response.data.length !== notifications.length |
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.
Expected blank line after variable declarations. (newline-after-var)
Missing semicolon. (semi)
if (loadTmp) { | ||
newNotifications = newData(response.data, notifications); | ||
|
||
page = response.has_next ? page+1 : page = 1 |
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.
Infix operators must be spaced. (space-infix-ops)
Missing semicolon. (semi)
newNotifications = newData(response.data, notifications); | ||
|
||
page = response.has_next ? page+1 : page = 1 | ||
console.log(page) |
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.
Unexpected console statement. (no-console)
Missing semicolon. (semi)
</li>`).join(' ')}`; | ||
|
||
// if (newItems) { | ||
container.prepend(tmp); |
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.
Expected indentation of 2 spaces but found 4. (indent)
var array = []; | ||
var observedArray = new Proxy(notifications, { | ||
set: function (target, propertyKey, value, receiver) { | ||
console.log(propertyKey+'='+value); |
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.
Expected indentation of 4 spaces but found 8. (indent)
Unexpected console statement. (no-console)
Infix operators must be spaced. (space-infix-ops)
var observedArray = new Proxy(notifications, { | ||
set: function (target, propertyKey, value, receiver) { | ||
console.log(propertyKey+'='+value); | ||
console.log(target,propertyKey, value ) |
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.
Expected indentation of 4 spaces but found 8. (indent)
Unexpected console statement. (no-console)
A space is required after ','. (comma-spacing)
There should be no spaces inside this paren. (space-in-parens)
Missing semicolon. (semi)
set: function (target, propertyKey, value, receiver) { | ||
console.log(propertyKey+'='+value); | ||
console.log(target,propertyKey, value ) | ||
target[propertyKey] = value; |
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.
Expected indentation of 4 spaces but found 8. (indent)
console.log(propertyKey+'='+value); | ||
console.log(target,propertyKey, value ) | ||
target[propertyKey] = value; | ||
return true |
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.
Expected indentation of 4 spaces but found 8. (indent)
Missing semicolon. (semi)
console.log(target,propertyKey, value ) | ||
target[propertyKey] = value; | ||
return true | ||
} |
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.
Expected indentation of 2 spaces but found 4. (indent)
Fix in inbox.views
if 'read' in req_body: | ||
for i in req_body['read']: | ||
entry = Notification.objects.filter(id=i) | ||
#if entry.to_user_id.id == request.user.id and len(entry) != 0: |
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.
E265 block comment should start with '# '
performance concerns:
|
Moved to #3221 without longpulling and vue.js as discussed |
Description
Checklist
Affected core subsystem(s)
Testing
Refers/Fixes
Refs: #2404