Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
cc595a39
authored
Mar 05, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add Notification.valid_until
parent
ec4f2a05
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
circle/dashboard/migrations/0006_auto__add_field_notification_valid_until.py
+0
-0
circle/dashboard/models.py
+9
-5
No files found.
circle/dashboard/migrations/0006_auto__add_field_notification_valid_until.py
0 → 100644
View file @
cc595a39
This diff is collapsed.
Click to expand it.
circle/dashboard/models.py
View file @
cc595a39
...
@@ -5,7 +5,8 @@ from django.conf import settings
...
@@ -5,7 +5,8 @@ from django.conf import settings
from
django.contrib.auth.models
import
User
,
Group
from
django.contrib.auth.models
import
User
,
Group
from
django.contrib.auth.signals
import
user_logged_in
from
django.contrib.auth.signals
import
user_logged_in
from
django.db.models
import
(
from
django.db.models
import
(
Model
,
ForeignKey
,
OneToOneField
,
CharField
,
IntegerField
,
TextField
Model
,
ForeignKey
,
OneToOneField
,
CharField
,
IntegerField
,
TextField
,
DateTimeField
,
)
)
from
django.template.loader
import
render_to_string
from
django.template.loader
import
render_to_string
from
django.utils.translation
import
ugettext_lazy
as
_
,
override
from
django.utils.translation
import
ugettext_lazy
as
_
,
override
...
@@ -34,12 +35,13 @@ class Notification(TimeStampedModel):
...
@@ -34,12 +35,13 @@ class Notification(TimeStampedModel):
to
=
ForeignKey
(
User
)
to
=
ForeignKey
(
User
)
subject
=
CharField
(
max_length
=
128
)
subject
=
CharField
(
max_length
=
128
)
message
=
TextField
()
message
=
TextField
()
valid_until
=
DateTimeField
(
null
=
True
,
default
=
None
)
class
Meta
:
class
Meta
:
ordering
=
[
'-created'
]
ordering
=
[
'-created'
]
@classmethod
@classmethod
def
send
(
cls
,
user
,
subject
,
template
,
context
=
{}):
def
send
(
cls
,
user
,
subject
,
template
,
context
=
{}
,
valid_until
=
None
):
try
:
try
:
language
=
user
.
profile
.
preferred_language
language
=
user
.
profile
.
preferred_language
except
:
except
:
...
@@ -48,7 +50,8 @@ class Notification(TimeStampedModel):
...
@@ -48,7 +50,8 @@ class Notification(TimeStampedModel):
context
[
'user'
]
=
user
context
[
'user'
]
=
user
rendered
=
render_to_string
(
template
,
context
)
rendered
=
render_to_string
(
template
,
context
)
subject
=
unicode
(
subject
)
subject
=
unicode
(
subject
)
return
cls
.
objects
.
create
(
to
=
user
,
subject
=
subject
,
message
=
rendered
)
return
cls
.
objects
.
create
(
to
=
user
,
subject
=
subject
,
message
=
rendered
,
valid_until
=
valid_until
)
class
Profile
(
Model
):
class
Profile
(
Model
):
...
@@ -62,8 +65,9 @@ class Profile(Model):
...
@@ -62,8 +65,9 @@ class Profile(Model):
help_text
=
_
(
'Unique identifier of the person, e.g. a student number.'
))
help_text
=
_
(
'Unique identifier of the person, e.g. a student number.'
))
instance_limit
=
IntegerField
(
default
=
5
)
instance_limit
=
IntegerField
(
default
=
5
)
def
notify
(
self
,
subject
,
template
,
context
=
{}):
def
notify
(
self
,
subject
,
template
,
context
=
{},
valid_until
=
None
):
return
Notification
.
send
(
self
.
user
,
subject
,
template
,
context
)
return
Notification
.
send
(
self
.
user
,
subject
,
template
,
context
,
valid_until
)
class
GroupProfile
(
AclBase
):
class
GroupProfile
(
AclBase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment