Commit e63c390c authored by Patrick's avatar Patrick

Test successful : Send SMS with free gateway : Sms Gateway - Android. TODO :...

Test successful : Send SMS with free gateway : Sms Gateway - Android. TODO : Try it with the workflow.
parent d196f30e
......@@ -50,6 +50,7 @@ try:
DJANGO_SETTINGS_SITE_NAME = os.path.split(PROJECT_DIR)[-1]
DJANGO_SETTINGS_CACHE = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_CACHE')
DJANGO_SETTINGS_SESSION = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_SESSION')
DJANGO_SETTINGS_ANDROID_SMS_GATEWAY_MAIL = config.get('DJANGO_SETTINGS', 'DJANGO_SETTINGS_ANDROID_SMS_GATEWAY_MAIL')
DJANGO_SETTINGS_ALLOWED_HOSTS = []
for name in config.options('ALLOWED_HOSTS'):
DJANGO_SETTINGS_ALLOWED_HOSTS.append(config.get('ALLOWED_HOSTS', name))
......@@ -61,6 +62,8 @@ except IOError:
print ("Unable to open %s settings" % (conf_file_name,))
raise SystemExit(-1)
###################### ANDROID SMS GATEWAY MAIL
ANDROID_SMS_GATEWAY_MAIL = DJANGO_SETTINGS_ANDROID_SMS_GATEWAY_MAIL
###################### DEBUG
DEBUG = DJANGO_SETTINGS_DEBUG
......@@ -240,7 +243,7 @@ CKEDITOR_SETTINGS = {
'toolbar_CMS': [
['Undo', 'Redo'],
['cmsplugins', '-', 'ShowBlocks'],
['Format', 'Templates'],
['Format',],
['TextColor', 'BGColor', '-', 'PasteText'],
['Maximize', ''],
'/',
......@@ -275,9 +278,15 @@ CKEDITOR_SETTINGS = {
# 'contentsCss' : '//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css',
'contentsCss': '%sbootstrap/css/bootstrap.css' % STATIC_URL,
# 'extraAllowedContent' : '*(*)',
'removeFormatTags': 'big,code,del,dfn,em,font,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,u,var',
# 'extraAllowedContent' : 'iframe[*]',
# 'removeFormatTags': 'big,code,del,dfn,em,font,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,u,var',
# NOTE: Some versions of CKEditor will pre-sanitize your text before
# passing it to the web server, rendering the above settings useless.
# To ensure this does not happen, you may need to add
# the following parameters to CKEDITOR_SETTINGS:
'basicEntities': False,
'entities': False,
# Do not dispaly the HTML Path below the edit window
'removePlugins': 'elementspath',
}
......@@ -298,13 +307,17 @@ CKEDITOR_SETTINGS_MODEL2 = {
'removePlugins': 'elementspath',
}
TEXT_ADDITIONAL_TAGS = ('span',)
TEXT_ADDITIONAL_ATTRIBUTES = ('class',)
TEXT_HTML_SANITIZE = True
# TEXT_SAVE_IMAGE_FUNCTION = 'cmsplugin_filer_image.integrations.ckeditor.create_image_plugin'
# TEXT_SAVE_IMAGE_FUNCTION = 'djangocms_text_ckeditor.picture_save.create_picture_plugin'
TEXT_SAVE_IMAGE_FUNCTION = None
TEXT_PLUGINS_INTEGRATION = 'buttons'
# djangocms-text-ckeditor uses html5lib to sanitize HTML
# to avoid security issues and to check for correct HTML code.
# Sanitisation may strip tags usesful for some use cases such as iframe;
# you may customize the tags and attributes allowed by overriding
# the TEXT_ADDITIONAL_TAGS and TEXT_ADDITIONAL_ATTRIBUTES settings:
TEXT_ADDITIONAL_TAGS = ('span', 'iframe',)
TEXT_ADDITIONAL_ATTRIBUTES = ('class', 'scrolling', 'allowfullscreen', 'frameborder')
TEXT_HTML_SANITIZE = True
FILER_ENABLE_LOGGING = False
FILER_IMAGE_USE_ICON = True
......
......@@ -10,6 +10,7 @@ from import_export.admin import ImportExportMixin, ExportMixin
from import_export.widgets import DateWidget, ForeignKeyWidget
import parler
from fkey_choice_cache_mixin import ForeignKeyCacheMixin
from repanier.email.email_alert import send_sms
from widget import SelectAdminOrderUnitWidget, PreviewProductOrderWidget
from xlsx.widget import TwoDecimalsWidget, TranslatedForeignKeyWidget, ThreeDecimalsWidget, OneToOneWidget, \
DecimalBooleanWidget, FourDecimalsWidget, ZeroDecimalsWidget, IdWidget
......@@ -1141,7 +1142,8 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
'export_xlsx_producer_order',
# 'import_xlsx_stock',
'generate_next_week',
'generate_next_12_week'
'generate_next_12_week',
"test"
]
def get_readonly_fields(self, request, obj=None):
......@@ -1161,6 +1163,11 @@ class PermanenceInPreparationAdmin(TranslatableAdmin):
export_xlsx_customer_order.short_description = _("Export xlsx customers orders")
def test(self, request, queryset):
return send_sms(sms_nr="+32 499 96 64 32 (pat)", sms_msg="Test SMS v8")
test.short_description = _("Test")
# def import_xlsx_stock(self, request, queryset):
# return xslx_stock.admin_import(self, admin, request, queryset, action='import_xlsx_stock')
#
......
......@@ -3,7 +3,9 @@ from __future__ import unicode_literals
import repanier.apps
from repanier.const import *
from django.conf import settings
from django.core.mail import send_mail
from django.core.mail import send_mail, EmailMessage
# from django.contrib.sites.models import get_current_site
......@@ -22,6 +24,28 @@ def send_error(error_str):
except:
pass
def send_sms(sms_nr=None, sms_msg=None):
try:
if sms_nr is not None and sms_msg is not None:
valid_nr = "0"
i = 0
while i < len(sms_nr) and not sms_nr[i] == '4':
i += 1
while i < len(sms_nr):
if '0' <= sms_nr[i] <= '9':
valid_nr += sms_nr[i]
i += 1
if len(valid_nr) == 10:
# Send SMS with free gateway : Sms Gateway - Android.
email = EmailMessage(valid_nr, sms_msg, "no-reply@repanier.be",
[settings.ANDROID_SMS_GATEWAY_MAIL,])
email.send()
except:
pass
# subject, from_email, to = 'Order Confirmation', 'admin@yourdomain.com', 'someone@somewhere.com'
# html_content = render_to_string('the_template.html', {'varname':'value'}) # ...
......
......@@ -12,6 +12,7 @@ from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
from parler.models import TranslationDoesNotExist
import repanier.apps
from repanier.email.email_alert import send_sms
from repanier.models import Permanence, Producer, OfferItem
from repanier.models import Customer
from repanier.tools import *
......@@ -52,6 +53,7 @@ def send_pre_open_order(permanence_id):
)
email.attach_alternative(html_content, "text/html")
send_email(email=email)
send_sms(sms_nr=producer.phone1, sms_msg="%s - %s - %s" % (_("Pre-opening of orders")))
def send_open_order(permanence_id):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment