Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c3dcd075
authored
Feb 17, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add notification model
parent
61cfbebd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletions
+35
-1
circle/dashboard/migrations/0005_auto__add_notification.py
+0
-0
circle/dashboard/models.py
+35
-1
No files found.
circle/dashboard/migrations/0005_auto__add_notification.py
0 → 100644
View file @
c3dcd075
This diff is collapsed.
Click to expand it.
circle/dashboard/models.py
View file @
c3dcd075
...
...
@@ -7,7 +7,12 @@ from django.contrib.auth.signals import user_logged_in
from
django.db.models
import
(
Model
,
ForeignKey
,
OneToOneField
,
CharField
,
IntegerField
,
TextField
)
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.template.loader
import
render_to_string
from
django.utils.translation
import
ugettext_lazy
as
_
,
override
from
model_utils.models
import
TimeStampedModel
from
model_utils.fields
import
StatusField
from
model_utils
import
Choices
from
vm.models
import
Instance
from
acl.models
import
AclBase
...
...
@@ -20,6 +25,32 @@ class Favourite(Model):
user
=
ForeignKey
(
User
)
class
Notification
(
TimeStampedModel
):
STATUS
=
Choices
((
'new'
,
_
(
'new'
)),
(
'delivered'
,
_
(
'delivered'
)),
(
'read'
,
_
(
'read'
)))
status
=
StatusField
()
to
=
ForeignKey
(
User
)
subject
=
CharField
(
max_length
=
128
)
message
=
TextField
()
class
Meta
:
ordering
=
[
'-created'
]
@classmethod
def
send
(
cls
,
user
,
subject
,
template
,
context
=
{}):
try
:
language
=
user
.
profile
.
preferred_language
except
:
language
=
None
with
override
(
language
):
context
[
'user'
]
=
user
rendered
=
render_to_string
(
template
,
context
)
subject
=
unicode
(
subject
)
return
cls
.
objects
.
create
(
to
=
user
,
subject
=
subject
,
message
=
rendered
)
class
Profile
(
Model
):
user
=
OneToOneField
(
User
)
preferred_language
=
CharField
(
verbose_name
=
_
(
'preferred language'
),
...
...
@@ -31,6 +62,9 @@ class Profile(Model):
help_text
=
_
(
'Unique identifier of the person, e.g. a student number.'
))
instance_limit
=
IntegerField
(
default
=
5
)
def
notify
(
self
,
subject
,
template
,
context
=
{}):
return
Notification
.
send
(
self
.
user
,
subject
,
template
,
context
)
class
GroupProfile
(
AclBase
):
ACL_LEVELS
=
(
...
...
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