-
Notifications
You must be signed in to change notification settings - Fork 227
Notifications app for yaksh #709
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
Open
CruiseDevice
wants to merge
13
commits into
FOSSEE:master
Choose a base branch
from
CruiseDevice:notifications
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
48e81cc
Course deadline notification task
CruiseDevice 30c79fd
Send quiz deadline notifications to user
CruiseDevice c733e55
Merge branch 'master' of https://github.com/FOSSEE/online_test into n…
CruiseDevice 5a02315
Resolve comments
CruiseDevice dabcbb4
Remove crontab import from settings.py
CruiseDevice 0b0410c
Send a course deadline notification by email
CruiseDevice 9e9c359
Merge branch 'master' of https://github.com/FOSSEE/online_test into n…
CruiseDevice 6416f79
Show notifications on student interface
CruiseDevice 61737df
Create quizzes list of each course
CruiseDevice 47a34ce
Use GenericForeignKey instead of ForeignKey
CruiseDevice 131a16a
Multiple improvements
CruiseDevice c487fb1
PEP8 fix and minor changes
CruiseDevice 9cc2398
Notify teacher and user when post created
CruiseDevice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class NotificationConfig(AppConfig): | ||
| name = 'notification' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.db import models | ||
|
|
||
| # Create your models here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| from textwrap import dedent | ||
|
|
||
| from django.utils import timezone | ||
|
|
||
| from celery import task | ||
| from notifications_plugin.models import NotificationMessage, Notification | ||
|
|
||
| from yaksh.models import Course, Quiz, QuestionPaper, AnswerPaper | ||
|
|
||
|
|
||
| @task(name='course_deadline_task') | ||
| def course_deadline_task(): | ||
| courses = Course.objects.filter(active=True, is_trial=False) | ||
| for course in courses: | ||
| if course.is_active_enrollment(): | ||
| message = dedent(""" | ||
| The deadline for the course {0} is {1}, please complete | ||
| the course if not completed before the deadline. | ||
| """.format(course.name, course.end_enroll_time) | ||
| ) | ||
| students = course.students.all() | ||
| creator = course.creator | ||
| if students: | ||
| students_id = students.values_list('id', flat=True) | ||
| notification_type = "warning" | ||
| nm = NotificationMessage.objects.add_single_message( | ||
| creator_id=creator.id, summary='Course Notification', | ||
| description=message, msg_type=notification_type | ||
| ) | ||
| Notification.objects.add_bulk_user_notifications( | ||
| receiver_ids=students_id, msg_id=nm.id | ||
| ) | ||
|
|
||
|
|
||
| @task(name='quiz_deadline_task') | ||
| def quiz_deadline_task(): | ||
| courses = Course.objects.filter(active=True, is_trial=False) | ||
| for course in courses: | ||
| students = course.students.all() | ||
| students_id = students.values_list('id', flat=True) | ||
CruiseDevice marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| creator = course.creator | ||
| modules = course.learning_module.all() | ||
| for module in modules: | ||
| units = module.learning_unit.all() | ||
| for unit in units: | ||
| if unit.type == 'quiz': | ||
CruiseDevice marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| quiz = unit.quiz | ||
| if not quiz.is_expired(): | ||
| message = dedent(""" | ||
| The deadline for the quiz {0} is {1}, please | ||
| complete the quiz if not completed before the | ||
| deadline. | ||
| """.format(quiz, quiz.end_date_time) | ||
| ) | ||
| notification_type = 'warning' | ||
| nm = NotificationMessage.objects.add_single_message( | ||
| creator_id=creator.id, summary='Quiz Notification', | ||
| description=message, msg_type=notification_type | ||
| ) | ||
| Notification.objects.add_bulk_user_notifications( | ||
| receiver_ids=students_id, msg_id=nm.id | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.test import TestCase | ||
|
|
||
| # Create your tests here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from django.shortcuts import render | ||
|
|
||
| # Create your views here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.