Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
ae0b7699
Commit
ae0b7699
authored
Jan 15, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish weekmail, and fix preferences page
parent
147809bb
Pipeline
#729
passed with stage
in 3 minutes
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
71 deletions
+65
-71
com/migrations/0003_auto_20170115_2300.py
com/migrations/0003_auto_20170115_2300.py
+8
-8
com/migrations/0004_auto_20170107_1222.py
com/migrations/0004_auto_20170107_1222.py
+0
-24
com/models.py
com/models.py
+1
-0
com/templates/com/weekmail_renderer_html.jinja
com/templates/com/weekmail_renderer_html.jinja
+45
-33
core/migrations/0019_preferences_receive_weekmail.py
core/migrations/0019_preferences_receive_weekmail.py
+1
-1
core/views/user.py
core/views/user.py
+10
-5
No files found.
com/migrations/0003_auto_201701
03_1341
.py
→
com/migrations/0003_auto_201701
15_2300
.py
View file @
ae0b7699
...
...
@@ -8,8 +8,8 @@ from django.conf import settings
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'club'
,
'0006_auto_20161229_0040'
),
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
'com'
,
'0002_news_newsdate'
),
]
...
...
@@ -17,8 +17,8 @@ class Migration(migrations.Migration):
migrations
.
CreateModel
(
name
=
'Weekmail'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
'ID'
,
serialize
=
False
,
auto_created
=
True
)),
(
'title'
,
models
.
CharField
(
verbose_name
=
'title'
,
max_length
=
64
)),
(
'id'
,
models
.
AutoField
(
serialize
=
False
,
primary_key
=
True
,
verbose_name
=
'ID'
,
auto_created
=
True
)),
(
'title'
,
models
.
CharField
(
max_length
=
64
,
verbose_name
=
'title'
,
blank
=
True
)),
(
'intro'
,
models
.
TextField
(
verbose_name
=
'intro'
,
blank
=
True
)),
(
'joke'
,
models
.
TextField
(
verbose_name
=
'joke'
,
blank
=
True
)),
(
'protip'
,
models
.
TextField
(
verbose_name
=
'protip'
,
blank
=
True
)),
...
...
@@ -32,13 +32,13 @@ class Migration(migrations.Migration):
migrations
.
CreateModel
(
name
=
'WeekmailArticle'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
'ID'
,
serialize
=
False
,
auto_created
=
True
)),
(
'title'
,
models
.
CharField
(
verbose_name
=
'title'
,
max_length
=
64
)),
(
'id'
,
models
.
AutoField
(
serialize
=
False
,
primary_key
=
True
,
verbose_name
=
'ID'
,
auto_created
=
True
)),
(
'title'
,
models
.
CharField
(
max_length
=
64
,
verbose_name
=
'title'
)),
(
'content'
,
models
.
TextField
(
verbose_name
=
'content'
)),
(
'rank'
,
models
.
IntegerField
(
verbose_name
=
'rank'
,
default
=-
1
)),
(
'author'
,
models
.
ForeignKey
(
related_name
=
'owned_weekmail_articles'
,
to
=
settings
.
AUTH_USER_MODEL
,
verbose_name
=
'author
'
)),
(
'club'
,
models
.
ForeignKey
(
related_name
=
'weekmail_articles'
,
to
=
'club.Club'
,
verbose_name
=
'club
'
)),
(
'weekmail'
,
models
.
ForeignKey
(
related_name
=
'articles'
,
to
=
'com.Weekmail'
,
verbose_name
=
'weekmail'
)),
(
'author'
,
models
.
ForeignKey
(
to
=
settings
.
AUTH_USER_MODEL
,
verbose_name
=
'author'
,
related_name
=
'owned_weekmail_articles
'
)),
(
'club'
,
models
.
ForeignKey
(
to
=
'club.Club'
,
verbose_name
=
'club'
,
related_name
=
'weekmail_articles
'
)),
(
'weekmail'
,
models
.
ForeignKey
(
to
=
'com.Weekmail'
,
verbose_name
=
'weekmail'
,
related_name
=
'articles'
,
null
=
True
)),
],
),
migrations
.
AddField
(
...
...
com/migrations/0004_auto_20170107_1222.py
deleted
100644 → 0
View file @
147809bb
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'com'
,
'0003_auto_20170103_1341'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'weekmail'
,
name
=
'title'
,
field
=
models
.
CharField
(
verbose_name
=
'title'
,
max_length
=
64
,
blank
=
True
),
),
migrations
.
AlterField
(
model_name
=
'weekmailarticle'
,
name
=
'weekmail'
,
field
=
models
.
ForeignKey
(
related_name
=
'articles'
,
to
=
'com.Weekmail'
,
verbose_name
=
'weekmail'
,
null
=
True
),
),
]
com/models.py
View file @
ae0b7699
...
...
@@ -84,6 +84,7 @@ class Weekmail(models.Model):
def
send
(
self
):
dest
=
[
i
[
0
]
for
i
in
Preferences
.
objects
.
filter
(
receive_weekmail
=
True
).
values_list
(
'user__email'
)]
print
(
dest
)
with
transaction
.
atomic
():
email
=
EmailMultiAlternatives
(
subject
=
self
.
title
,
...
...
com/templates/com/weekmail_renderer_html.jinja
View file @
ae0b7699
<h2>
{{
weekmail.title
}}
</h2>
{%
if
weekmail.intro
%}
<h3>
{%
trans
%}
Intro
{%
endtrans
%}
</h3>
{{
weekmail.intro
|
markdown
}}
{%
endif
%}
<h3>
{%
trans
%}
Table of content
{%
endtrans
%}
</h3>
<ul>
{%
for
a
in
weekmail.articles.all
()
%}
<li>
[
{{
a.club
}}
]
{{
a.title
}}
</li>
{%
-
endfor
%}
</ul>
{%
-
for
a
in
weekmail.articles.all
()
%}
<h3>
[
{{
a.club
}}
]
{{
a.title
}}
</h3>
{{
a.content
|
markdown
}}
{%
-
endfor
-
%}
{%
-
if
weekmail.joke
%}
<h3>
{%
trans
%}
Joke
{%
endtrans
%}
</h3>
{{
weekmail.joke
|
markdown
}}
{%
endif
-
%}
{%
-
if
weekmail.protip
%}
<h3>
{%
trans
%}
Pro tip
{%
endtrans
%}
</h3>
{{
weekmail.protip
|
markdown
}}
{%
endif
-
%}
{%
-
if
weekmail.conclusion
%}
<h3>
{%
trans
%}
Final word
{%
endtrans
%}
</h3>
{{
weekmail.conclusion
|
markdown
}}
{%
endif
-
%}
<style
type=
"text/css"
media=
"all"
>
h1
,
h2
,
h3
,
h4
,
h5
,
h6
,
p
{
padding
:
5px
;
margin
:
5px
;
}
</style>
<div
style=
"background: black; padding: 0px 5%;"
>
<div
style=
"background: white;"
>
<h2
style=
"background: lightblue;"
>
{{
weekmail.title
}}
</h2>
{%
if
weekmail.intro
%}
<h3
style=
"background: black; color: white"
>
{%
trans
%}
Intro
{%
endtrans
%}
</h3>
{{
weekmail.intro
|
markdown
}}
{%
endif
%}
<h3
style=
"background: black; color: white"
>
{%
trans
%}
Table of content
{%
endtrans
%}
</h3>
<ul>
{%
for
a
in
weekmail.articles.all
()
%}
<li>
[
{{
a.club
}}
]
{{
a.title
}}
</li>
{%
-
endfor
%}
</ul>
{%
-
for
a
in
weekmail.articles.all
()
%}
<h3
style=
"background: lightblue;"
>
[
{{
a.club
}}
]
{{
a.title
}}
</h3>
{{
a.content
|
markdown
}}
{%
-
endfor
-
%}
{%
-
if
weekmail.joke
%}
<h3
style=
"background: black; color: white"
>
{%
trans
%}
Joke
{%
endtrans
%}
</h3>
{{
weekmail.joke
|
markdown
}}
{%
endif
-
%}
{%
-
if
weekmail.protip
%}
<h3
style=
"background: black; color: white"
>
{%
trans
%}
Pro tip
{%
endtrans
%}
</h3>
{{
weekmail.protip
|
markdown
}}
{%
endif
-
%}
{%
-
if
weekmail.conclusion
%}
<h3
style=
"background: black; color: white"
>
{%
trans
%}
Final word
{%
endtrans
%}
</h3>
{{
weekmail.conclusion
|
markdown
}}
{%
endif
-
%}
</div>
</div>
core/migrations/0019_preferences_receive_weekmail.py
View file @
ae0b7699
...
...
@@ -14,6 +14,6 @@ class Migration(migrations.Migration):
migrations
.
AddField
(
model_name
=
'preferences'
,
name
=
'receive_weekmail'
,
field
=
models
.
BooleanField
(
verbose_name
=
'define if we want to receive the weekmail'
,
default
=
False
,
help_text
=
'D
o you want to receive the weekmail'
),
field
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'd
o you want to receive the weekmail'
),
),
]
core/views/user.py
View file @
ae0b7699
...
...
@@ -387,21 +387,26 @@ class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView):
"""
Edit a user's preferences
"""
model
=
Preferences
model
=
User
pk_url_kwarg
=
"user_id"
template_name
=
"core/edit.jinja"
f
ields
=
[
'receive_weekmail'
]
f
orm_class
=
modelform_factory
(
Preferences
,
fields
=
[
'receive_weekmail'
])
context_object_name
=
"profile"
current_tab
=
"prefs"
def
get_object
(
self
,
queryset
=
None
):
user
=
get_object_or_404
(
User
,
pk
=
self
.
kwargs
[
'user_id'
])
return
user
def
get_form_kwargs
(
self
):
kwargs
=
super
(
UserPreferencesView
,
self
).
get_form_kwargs
()
try
:
return
user
.
preferences
pref
=
self
.
object
.
preferences
except
:
pref
=
Preferences
(
user
=
user
)
pref
=
Preferences
(
user
=
self
.
object
)
pref
.
save
()
return
pref
kwargs
.
update
({
'instance'
:
pref
})
return
kwargs
class
UserUpdateGroupView
(
UserTabsMixin
,
CanEditPropMixin
,
UpdateView
):
"""
...
...
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