Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
repanier
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chris
repanier
Commits
4ba251ca
Commit
4ba251ca
authored
Jun 18, 2017
by
Patrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add : custom mail server.
parent
41e49235
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1336 additions
and
1457 deletions
+1336
-1457
repanier/admin/configuration.py
repanier/admin/configuration.py
+7
-11
repanier/locale/fr/LC_MESSAGES/django.mo
repanier/locale/fr/LC_MESSAGES/django.mo
+0
-0
repanier/locale/fr/LC_MESSAGES/django.po
repanier/locale/fr/LC_MESSAGES/django.po
+1304
-1432
repanier/models/configuration.py
repanier/models/configuration.py
+4
-1
repanier/tools.py
repanier/tools.py
+16
-11
repanier/views/login_view.py
repanier/views/login_view.py
+5
-2
No files found.
repanier/admin/configuration.py
View file @
4ba251ca
...
...
@@ -56,8 +56,11 @@ class ConfigurationDataForm(TranslatableModelForm):
'send_abstract_order_mail_to_customer'
,
_
(
'The abstract can only be send if the order is also send to producer'
))
email_host_password
=
self
.
cleaned_data
[
"email_host_password"
]
if
email_host_password
:
email_is_custom
=
self
.
cleaned_data
[
"email_is_custom"
]
if
email_is_custom
:
# Send test email
if
not
email_host_password
:
email_host_password
=
self
.
instance
.
previous_email_host_password
email_host
=
self
.
cleaned_data
[
"email_host"
]
email_port
=
self
.
cleaned_data
[
"email_port"
]
email_use_tls
=
self
.
cleaned_data
[
"email_use_tls"
]
...
...
@@ -71,8 +74,9 @@ class ConfigurationDataForm(TranslatableModelForm):
)
if
not
email_send
:
self
.
add_error
(
'email_
host_password
'
,
'email_
is_custom
'
,
_
(
'Repanier tried to send a test email without success.'
))
self
.
instance
.
email_is_custom
=
False
class
Meta
:
model
=
Configuration
...
...
@@ -162,18 +166,10 @@ class ConfigurationAdmin(TranslatableAdmin):
'invoice'
,
(
'currency'
,
'vat_id'
),
'sms_gateway_mail'
,
'email_is_custom'
,
(
'email_host'
,
'email_port'
,
'email_use_tls'
),
(
'email_host_user'
,
'email_host_password'
)
),
}),
]
return
fieldsets
# def get_readonly_fields(self, request, configuration=None):
# permanence = Permanence.objects.all().order_by('?')
# is_coordinator = request.user.is_superuser or request.user.is_staff
#
# if is_coordinator or not permanence.exists():
# return []
# else:
# return ['bank_account']
repanier/locale/fr/LC_MESSAGES/django.mo
View file @
4ba251ca
No preview for this file type
repanier/locale/fr/LC_MESSAGES/django.po
View file @
4ba251ca
This diff is collapsed.
Click to expand it.
repanier/models/configuration.py
View file @
4ba251ca
...
...
@@ -100,6 +100,8 @@ class Configuration(TranslatableModel):
default
=
DECIMAL_ZERO
,
max_digits
=
5
,
decimal_places
=
2
,
validators
=
[
MinValueValidator
(
0
)])
notification_is_public
=
models
.
BooleanField
(
_
(
"the notification is public"
),
default
=
False
)
email_is_custom
=
models
.
BooleanField
(
_
(
"Email is customised"
),
default
=
False
)
email_host
=
models
.
CharField
(
_
(
"email host"
),
help_text
=
_
(
"For @gmail.com, see: https://mail.google.com/mail/u/0/#settings/fwdandpop and activate POP"
),
...
...
@@ -107,6 +109,7 @@ class Configuration(TranslatableModel):
email_port
=
models
.
IntegerField
(
_
(
"email port"
),
help_text
=
_
(
"Usually 587 for @gmail.com, otherwise 25"
),
blank
=
True
,
null
=
True
,
default
=
587
)
email_use_tls
=
models
.
BooleanField
(
_
(
"email use tls"
),
...
...
@@ -311,7 +314,7 @@ def configuration_pre_save(sender, **kwargs):
config
=
kwargs
[
"instance"
]
if
not
config
.
bank_account
:
config
.
bank_account
=
None
if
not
config
.
email_host_password
:
if
config
.
email_is_custom
and
not
config
.
email_host_password
:
config
.
email_host_password
=
config
.
previous_email_host_password
...
...
repanier/tools.py
View file @
4ba251ca
...
...
@@ -102,6 +102,7 @@ def send_test_email(host=None, port=None, host_user=None, host_password=None, us
)
return
send_email
(
email
,
test
=
True
,
host
=
host
,
port
=
port
,
host_user
=
host_user
,
...
...
@@ -113,13 +114,15 @@ def send_test_email(host=None, port=None, host_user=None, host_password=None, us
def
send_email
(
email
=
None
,
from_name
=
EMPTY_STRING
,
track_customer_on_error
=
False
,
host
=
None
,
port
=
None
,
host_user
=
None
,
host_password
=
None
,
use_tls
=
None
):
test
=
False
,
host
=
None
,
port
=
None
,
host_user
=
None
,
host_password
=
None
,
use_tls
=
None
):
email_send
=
False
from_email
,
host
,
host_password
,
host_user
,
port
,
use_tls
=
send_email_get_connection_param
(
test
,
host
,
host_password
,
host_user
,
port
,
use_tls
)
if
settings
.
DJANGO_SETTINGS_DEMO
:
email
.
to
=
[
DEMO_EMAIL
]
email
.
cc
=
[]
email
.
bcc
=
[]
email_send
=
send_email_with_error_log
(
email
,
from_name
,
host
=
host
,
email_send
=
send_email_with_error_log
(
email
,
from_name
,
from_email
=
from_email
,
host
=
host
,
port
=
port
,
host_user
=
host_user
,
host_password
=
host_password
,
...
...
@@ -132,7 +135,7 @@ def send_email(
# Send the mail only if there is at least one tester
email
.
cc
=
[]
email
.
bcc
=
[]
email_send
=
send_email_with_error_log
(
email
,
from_name
,
host
=
host
,
email_send
=
send_email_with_error_log
(
email
,
from_name
,
from_email
=
from_email
,
host
=
host
,
port
=
port
,
host_user
=
host_user
,
host_password
=
host_password
,
...
...
@@ -158,7 +161,12 @@ def send_email(
customer
=
None
for
email_to
in
send_email_to
:
email
.
to
=
[
email_to
]
email_send
&=
send_email_with_error_log
(
email
,
from_name
,
track_customer_on_error
,
host
=
host
,
email_send
&=
send_email_with_error_log
(
email
,
from_name
,
track_customer_on_error
,
from_email
=
from_email
,
host
=
host
,
port
=
port
,
host_user
=
host_user
,
host_password
=
host_password
,
...
...
@@ -169,14 +177,11 @@ def send_email(
def
send_email_with_error_log
(
email
,
from_name
=
None
,
track_customer_on_error
=
False
,
host
=
None
,
port
=
None
,
host_user
=
None
,
host_password
=
None
,
use_tls
=
None
):
from_email
=
None
,
host
=
None
,
port
=
None
,
host_user
=
None
,
host_password
=
None
,
use_tls
=
None
):
email_send
=
False
email_to
=
email
.
to
[
0
]
customer
,
send_mail
=
send_email_get_customer
(
email_to
,
track_customer_on_error
)
if
send_mail
:
from_email
,
host
,
host_password
,
host_user
,
port
,
use_tls
=
send_email_get_connection_param
(
host
,
host_password
,
host_user
,
port
,
use_tls
)
try
:
with
mail
.
get_connection
(
host
=
host
,
port
=
port
,
username
=
host_user
,
password
=
host_password
,
use_tls
=
use_tls
,
use_ssl
=
not
use_tls
)
as
connection
:
email
.
connection
=
connection
...
...
@@ -232,16 +237,16 @@ def send_email_with_error_log(
return
email_send
def
send_email_get_connection_param
(
host
,
host_password
,
host_user
,
port
,
use_tls
):
def
send_email_get_connection_param
(
test
,
host
,
host_password
,
host_user
,
port
,
use_tls
):
from
repanier.apps
import
REPANIER_SETTINGS_CONFIG
config
=
REPANIER_SETTINGS_CONFIG
if
config
.
email_
host_password
and
not
settings
.
DJANGO_SETTINGS_DEMO
:
if
config
.
email_
is_custom
and
not
test
and
not
settings
.
DJANGO_SETTINGS_DEMO
:
host
=
config
.
email_host
port
=
config
.
email_port
from_email
=
host_user
=
config
.
email_host_user
host_password
=
config
.
email_host_password
use_tls
=
config
.
email_use_tls
elif
host
and
host_user
and
not
settings
.
DJANGO_SETTINGS_DEMO
:
if
test
and
not
settings
.
DJANGO_SETTINGS_DEMO
:
from_email
=
host_user
else
:
host
=
settings
.
EMAIL_HOST
...
...
repanier/views/login_view.py
View file @
4ba251ca
...
...
@@ -99,8 +99,11 @@ def login_view(request, template_name='repanier/registration/login.html',
return
HttpResponseRedirect
(
redirect_to
)
else
:
form
=
authentication_form
(
request
)
try
:
how_to_register
=
REPANIER_SETTINGS_CONFIG
.
safe_translation_getter
(
'how_to_register'
,
any_language
=
True
,
default
=
EMPTY_STRING
)
except
:
how_to_register
=
EMPTY_STRING
current_site
=
get_current_site
(
request
)
...
...
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