Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
ae9f4828
Commit
ae9f4828
authored
Nov 26, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial support for advertisements
parent
ed49bd13
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
337 additions
and
0 deletions
+337
-0
trans/migrations/0058_auto__add_advertisement.py
trans/migrations/0058_auto__add_advertisement.py
+257
-0
trans/models/__init__.py
trans/models/__init__.py
+1
-0
trans/models/advertisement.py
trans/models/advertisement.py
+79
-0
No files found.
trans/migrations/0058_auto__add_advertisement.py
0 → 100644
View file @
ae9f4828
This diff is collapsed.
Click to expand it.
trans/models/__init__.py
View file @
ae9f4828
...
@@ -34,6 +34,7 @@ from trans.models.unitdata import (
...
@@ -34,6 +34,7 @@ from trans.models.unitdata import (
from
trans.models.changes
import
Change
from
trans.models.changes
import
Change
from
trans.models.dictionary
import
Dictionary
from
trans.models.dictionary
import
Dictionary
from
trans.models.source
import
Source
from
trans.models.source
import
Source
from
trans.models.advertisement
import
Advertisement
@
receiver
(
post_delete
,
sender
=
Project
)
@
receiver
(
post_delete
,
sender
=
Project
)
...
...
trans/models/advertisement.py
0 → 100644
View file @
ae9f4828
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2013 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import
random
from
django.utils.translation
import
ugettext
as
_
,
ugettext_lazy
from
django.db
import
models
from
django.utils
import
timezone
class
AdvertisementManager
(
models
.
Manager
):
def
get_advertisement
(
self
,
placement
):
now
=
timezone
.
now
()
base
=
self
.
filter
(
placement
=
placement
,
date_start__lt
=
now
,
date_end__gt
=
now
)
count
=
base
.
count
()
if
count
==
0
:
return
None
offset
=
random
.
randint
(
0
,
count
-
1
)
return
base
[
offset
]
class
Advertisement
(
models
.
Model
):
PLACEMENT_MAIL_TEXT
=
1
PLACEMENT_MAIL_HTML
=
2
PLACEMENT_CHOICES
=
(
(
PLACEMENT_MAIL_TEXT
,
ugettext_lazy
(
'Mail footer (text)'
)),
(
PLACEMENT_MAIL_HTML
,
ugettext_lazy
(
'Mail footer (HTML)'
)),
)
placement
=
models
.
IntegerField
(
choices
=
PLACEMENT_CHOICES
,
verbose_name
=
ugettext_lazy
(
'Advertisement placement'
),
)
date_start
=
models
.
DateField
(
verbose_name
=
ugettext_lazy
(
'Advertisement start date'
),
)
date_end
=
models
.
DateField
(
verbose_name
=
ugettext_lazy
(
'Advertisement end date'
),
)
text
=
models
.
TextField
(
verbose_name
=
ugettext_lazy
(
'Advertisement text'
),
help_text
=
ugettext_lazy
(
'Depending on placement, HTML can be allowed.'
)
)
note
=
models
.
TextField
(
verbose_name
=
ugettext_lazy
(
'Note'
),
help_text
=
ugettext_lazy
(
'Free form note for your notes, not used within Weblate.'
),
blank
=
True
)
class
Meta
(
object
):
app_label
=
'trans'
index_together
=
[
(
'placement'
,
'date_start'
,
'date_end'
),
]
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