Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
8c9f02a1
Commit
8c9f02a1
authored
Aug 17, 2017
by
Sli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fetch function for DSI
parent
9cb88a87
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
1 deletion
+44
-1
club/models.py
club/models.py
+17
-0
club/templates/club/mailing.jinja
club/templates/club/mailing.jinja
+1
-1
club/templates/club/mailing_output.jinja
club/templates/club/mailing_output.jinja
+3
-0
club/urls.py
club/urls.py
+1
-0
club/views.py
club/views.py
+14
-0
sith/settings.py
sith/settings.py
+5
-0
sith/urls.py
sith/urls.py
+3
-0
No files found.
club/models.py
View file @
8c9f02a1
...
...
@@ -231,6 +231,11 @@ class Mailing(models.Model):
club
=
models
.
ForeignKey
(
Club
,
verbose_name
=
_
(
'Club'
),
related_name
=
"mailings"
,
null
=
False
,
blank
=
False
)
email
=
models
.
EmailField
(
_
(
'Email address'
),
unique
=
True
)
def
clean
(
self
):
if
'@'
+
settings
.
SITH_MAILING_ALLOWED_DOMAIN
not
in
self
.
email
:
raise
ValidationError
(
_
(
'Unothorized mailing domain'
))
super
(
Mailing
,
self
).
clean
()
def
is_owned_by
(
self
,
user
):
return
user
.
is_in_group
(
self
)
or
user
.
is_root
or
user
.
is_board_member
...
...
@@ -242,6 +247,15 @@ class Mailing(models.Model):
sub
.
delete
()
super
(
Mailing
,
self
).
delete
()
def
base_mail
(
self
):
return
self
.
email
.
split
(
'@'
)[
0
]
def
fetch_format
(
self
):
resp
=
self
.
base_mail
()
+
': '
for
sub
in
self
.
subscriptions
.
all
():
resp
+=
sub
.
fetch_format
()
return
resp
def
__str__
(
self
):
return
"%s - %s"
%
(
self
.
club
,
self
.
email
)
...
...
@@ -270,6 +284,9 @@ class MailingSubscription(models.Model):
def
can_be_edited_by
(
self
,
user
):
return
self
.
is_owned_by
(
user
)
or
(
user
is
not
None
and
user
.
id
==
self
.
user
.
id
)
def
fetch_format
(
self
):
return
self
.
email
+
' '
def
__str__
(
self
):
if
self
.
user
:
user
=
str
(
self
.
user
)
...
...
club/templates/club/mailing.jinja
View file @
8c9f02a1
...
...
@@ -10,7 +10,7 @@
{%
for
mailing
in
object_list
%}
<h2>
{%
trans
%}
Mailing
{%
endtrans
%}
{{
mailing.email
}}
{%
-
if
user.is_owner
(
mailing
)
-
%}
<a
href=
"
{{
url
(
'club:mailing_delete'
,
mailing_id
=
mailing.id
)
}}
"
>
{%
trans
%}
Delete
{%
endtrans
%}
</a>
<a
href=
"
{{
url
(
'club:mailing_delete'
,
mailing_id
=
mailing.id
)
}}
"
>
-
{%
trans
%}
Delete
{%
endtrans
%}
</a>
{%
-
endif
-
%}
</h2>
<hr>
...
...
club/templates/club/mailing_output.jinja
0 → 100644
View file @
8c9f02a1
{%
-
for
mailing
in
object_list
-
%}
{{
mailing.fetch_format
()
}}
{%
-
endfor
-
%}
\ No newline at end of file
club/urls.py
View file @
8c9f02a1
...
...
@@ -44,5 +44,6 @@ urlpatterns = [
url
(
r
'^(?P<club_id>[0-9]+)/mailing/new/subscription$'
,
ClubMailingView
.
as_view
(
action
=
MailingFormType
.
MEMBER
),
name
=
'mailing_subscription_create'
),
url
(
r
'^(?P<mailing_id>[0-9]+)/mailing/delete$'
,
MailingDeleteView
.
as_view
(),
name
=
'mailing_delete'
),
url
(
r
'^(?P<mailing_subscription_id>[0-9]+)/mailing/delete/subscription$'
,
MailingSubscriptionDeleteView
.
as_view
(),
name
=
'mailing_subscription_delete'
),
url
(
r
'^mailing/fetch$'
,
MailingFetchView
.
as_view
(),
name
=
'mailing_fetch'
),
url
(
r
'^membership/(?P<membership_id>[0-9]+)/set_old$'
,
MembershipSetOldView
.
as_view
(),
name
=
'membership_set_old'
),
]
club/views.py
View file @
8c9f02a1
...
...
@@ -44,6 +44,8 @@ from club.models import Club, Membership, Mailing, MailingSubscription
from
sith.settings
import
SITH_MAXIMUM_FREE_ROLE
from
counter.models
import
Selling
,
Counter
from
django.conf
import
settings
# Custom forms
...
...
@@ -505,3 +507,15 @@ class MailingSubscriptionDeleteView(CanEditMixin, DeleteView):
def
get_success_url
(
self
,
**
kwargs
):
return
reverse_lazy
(
'club:mailing'
,
kwargs
=
{
'club_id'
:
self
.
club_id
})
class
MailingFetchView
(
ListView
):
model
=
Mailing
template_name
=
'club/mailing_output.jinja'
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
key
=
request
.
GET
.
get
(
'key'
,
''
)
if
key
!=
settings
.
SITH_MAILING_FETCH_KEY
:
raise
PermissionDenied
return
super
(
MailingFetchView
,
self
).
dispatch
(
request
,
*
args
,
**
kwargs
)
sith/settings.py
View file @
8c9f02a1
...
...
@@ -586,3 +586,8 @@ if DEBUG:
SASS_INCLUDE_FOLDERS
=
[
'core/static/'
,
]
# Mailing related settings
SITH_MAILING_ALLOWED_DOMAIN
=
'utbm.fr'
SITH_MAILING_FETCH_KEY
=
'IloveMails'
sith/urls.py
View file @
8c9f02a1
...
...
@@ -43,6 +43,7 @@ from django.conf.urls.static import static
from
django.conf
import
settings
from
django.views.i18n
import
javascript_catalog
from
ajax_select
import
urls
as
ajax_select_urls
from
club.views
import
MailingFetchView
js_info_dict
=
{
'packages'
:
(
'sith'
,),
...
...
@@ -72,6 +73,8 @@ urlpatterns = [
url
(
r
'^ajax_select/'
,
include
(
ajax_select_urls
)),
url
(
r
'^i18n/'
,
include
(
'django.conf.urls.i18n'
)),
url
(
r
'^jsi18n/$'
,
javascript_catalog
,
js_info_dict
,
name
=
'javascript-catalog'
),
# This url is for legacy use
url
(
r
'^mailing.php$'
,
MailingFetchView
.
as_view
(),
name
=
'mailing_fetch_legacy'
),
]
if
settings
.
DEBUG
:
...
...
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