Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
08abf4b5
authored
Apr 27, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: use TimeFramedModel in Message
parent
c1e8f14e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
16 deletions
+9
-16
circle/dashboard/context_processors.py
+1
-6
circle/dashboard/forms.py
+1
-1
circle/dashboard/migrations/0003_message.py
+5
-3
circle/dashboard/models.py
+2
-6
No files found.
circle/dashboard/context_processors.py
View file @
08abf4b5
...
...
@@ -16,8 +16,6 @@
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.conf
import
settings
from
django.db.models
import
Q
from
django.utils
import
timezone
from
.models
import
Message
...
...
@@ -38,7 +36,4 @@ def extract_settings(request):
def
broadcast_messages
(
request
):
now
=
timezone
.
now
()
messages
=
Message
.
objects
.
filter
(
enabled
=
True
)
.
exclude
(
Q
(
starts_at__gt
=
now
)
|
Q
(
ends_at__lt
=
now
))
return
{
'broadcast_messages'
:
messages
}
return
{
'broadcast_messages'
:
Message
.
timeframed
.
filter
(
enabled
=
True
)}
circle/dashboard/forms.py
View file @
08abf4b5
...
...
@@ -1629,7 +1629,7 @@ class DiskForm(ModelForm):
class
MessageForm
(
ModelForm
):
class
Meta
:
model
=
Message
fields
=
(
"message"
,
"enabled"
,
"effect"
,
"start
s_at"
,
"ends_at
"
)
fields
=
(
"message"
,
"enabled"
,
"effect"
,
"start
"
,
"end
"
)
@property
def
helper
(
self
):
...
...
circle/dashboard/migrations/0003_message.py
View file @
08abf4b5
...
...
@@ -19,14 +19,16 @@ class Migration(migrations.Migration):
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
serialize
=
False
,
auto_created
=
True
,
primary_key
=
True
)),
(
'created'
,
model_utils
.
fields
.
AutoCreatedField
(
default
=
django
.
utils
.
timezone
.
now
,
verbose_name
=
'created'
,
editable
=
False
)),
(
'modified'
,
model_utils
.
fields
.
AutoLastModifiedField
(
default
=
django
.
utils
.
timezone
.
now
,
verbose_name
=
'modified'
,
editable
=
False
)),
(
'start'
,
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'start'
,
blank
=
True
)),
(
'end'
,
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'end'
,
blank
=
True
)),
(
'message'
,
models
.
CharField
(
max_length
=
500
,
verbose_name
=
'message'
)),
(
'starts_at'
,
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'starts at'
,
blank
=
True
)),
(
'ends_at'
,
models
.
DateTimeField
(
null
=
True
,
verbose_name
=
'ends at'
,
blank
=
True
)),
(
'effect'
,
models
.
CharField
(
default
=
b
'info'
,
max_length
=
10
,
verbose_name
=
'effect'
,
choices
=
[(
b
'success'
,
'success'
),
(
b
'info'
,
'info'
),
(
b
'warning'
,
'warning'
),
(
b
'danger'
,
'danger'
)])),
(
'enabled'
,
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'enabled'
)),
],
options
=
{
'ordering'
:
[
'-ends_at'
],
'ordering'
:
[
'id'
],
'verbose_name'
:
'message'
,
'verbose_name_plural'
:
'messages'
,
},
bases
=
(
models
.
Model
,),
),
...
...
circle/dashboard/models.py
View file @
08abf4b5
...
...
@@ -39,7 +39,7 @@ from django.core.exceptions import ObjectDoesNotExist
from
sizefield.models
import
FileSizeField
from
jsonfield
import
JSONField
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
Time
FramedModel
,
Time
StampedModel
from
model_utils.fields
import
StatusField
from
model_utils
import
Choices
...
...
@@ -59,12 +59,8 @@ def pwgen():
return
User
.
objects
.
make_random_password
()
class
Message
(
TimeStampedModel
):
class
Message
(
TimeStampedModel
,
TimeFramedModel
):
message
=
CharField
(
max_length
=
500
,
verbose_name
=
_
(
'message'
))
starts_at
=
DateTimeField
(
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'starts at'
))
ends_at
=
DateTimeField
(
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'ends at'
))
effect
=
CharField
(
default
=
'info'
,
max_length
=
10
,
verbose_name
=
_
(
'effect'
),
choices
=
((
'success'
,
_
(
'success'
)),
(
'info'
,
_
(
'info'
)),
...
...
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