resolve base.py conflict
This commit is contained in:
		
					parent
					
						
							
								5e51fa6dbf
							
						
					
				
			
			
				commit
				
					
						fbbee2839c
					
				
			
		
					 6 changed files with 98 additions and 51 deletions
				
			
		| 
						 | 
				
			
			@ -30,7 +30,7 @@ dotenv.read_dotenv("{0}/.env".format(PROJECT_DIR))
 | 
			
		|||
SITE_ID = 1
 | 
			
		||||
 | 
			
		||||
APP_ROOT_ENDPOINT = "/"
 | 
			
		||||
APPEND_SLASH=True
 | 
			
		||||
APPEND_SLASH = True
 | 
			
		||||
 | 
			
		||||
LOGIN_URL = None
 | 
			
		||||
LOGOUT_URL = None
 | 
			
		||||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ SECRET_KEY = env('DJANGO_SECRET_KEY')
 | 
			
		|||
# Application definition
 | 
			
		||||
 | 
			
		||||
INSTALLED_APPS = (
 | 
			
		||||
    #1st migrate
 | 
			
		||||
    # 1st migrate
 | 
			
		||||
    'membership',
 | 
			
		||||
    'django.contrib.admin',
 | 
			
		||||
    'django.contrib.auth',
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +79,7 @@ INSTALLED_APPS = (
 | 
			
		|||
    'menus',  # helper for model independent hierarchical website navigation
 | 
			
		||||
    'cmsplugin_filer_image',
 | 
			
		||||
 | 
			
		||||
    #2nd migrate
 | 
			
		||||
    # 2nd migrate
 | 
			
		||||
    # django-cms plugins
 | 
			
		||||
    'djangocms_file',
 | 
			
		||||
    'djangocms_picture',
 | 
			
		||||
| 
						 | 
				
			
			@ -98,7 +98,7 @@ INSTALLED_APPS = (
 | 
			
		|||
    # 'cmsplugin_filer_teaser',
 | 
			
		||||
    'cmsplugin_filer_video',
 | 
			
		||||
    #
 | 
			
		||||
    #blog
 | 
			
		||||
    # blog
 | 
			
		||||
    # versioning
 | 
			
		||||
    'reversion',
 | 
			
		||||
    # ungleich
 | 
			
		||||
| 
						 | 
				
			
			@ -128,16 +128,15 @@ MIDDLEWARE_CLASSES = (
 | 
			
		|||
 | 
			
		||||
ROOT_URLCONF = 'dynamicweb.urls'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TEMPLATES = [
 | 
			
		||||
    {
 | 
			
		||||
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
 | 
			
		||||
        'DIRS': [os.path.join(PROJECT_DIR,'cms_templates/'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR,'cms_templates/djangocms_blog/'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR,'membership'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR,'ungleich/templates/djangocms_blog/'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR,'ungleich/templates/cms/ungleichch'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR,'ungleich/templates/ungleich')
 | 
			
		||||
        'DIRS': [os.path.join(PROJECT_DIR, 'cms_templates/'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR, 'cms_templates/djangocms_blog/'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR, 'membership'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR, 'ungleich/templates/djangocms_blog/'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR, 'ungleich/templates/cms/ungleichch'),
 | 
			
		||||
                 os.path.join(PROJECT_DIR, 'ungleich/templates/ungleich')
 | 
			
		||||
 | 
			
		||||
                 ],
 | 
			
		||||
        'APP_DIRS': True,
 | 
			
		||||
| 
						 | 
				
			
			@ -170,7 +169,7 @@ CMS_TEMPLATES = (
 | 
			
		|||
    ('letscowork.html', gettext('DG.CoWork')),
 | 
			
		||||
    # ('detail.html', gettext('DG.Detail')),
 | 
			
		||||
    ('one_column.html', gettext('DG.OneColumn')),
 | 
			
		||||
    #ungleich
 | 
			
		||||
    # ungleich
 | 
			
		||||
    ('blog_ungleich.html', gettext('Blog')),
 | 
			
		||||
    ('page.html', gettext('Page')),
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -205,7 +204,7 @@ LANGUAGE_CODE = 'en-us'
 | 
			
		|||
 | 
			
		||||
LOCALE_PATHS = [
 | 
			
		||||
 | 
			
		||||
    os.path.join(PROJECT_DIR,'digitalglarus/locale'),
 | 
			
		||||
    os.path.join(PROJECT_DIR, 'digitalglarus/locale'),
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CMS_PLACEHOLDER_CONF = {
 | 
			
		||||
| 
						 | 
				
			
			@ -332,9 +331,9 @@ STATICFILES_FINDERS = (
 | 
			
		|||
    'compressor.finders.CompressorFinder',
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
#COMPRESS_PRECOMPILERS = (
 | 
			
		||||
# COMPRESS_PRECOMPILERS = (
 | 
			
		||||
#    ('text/less', 'lesscpy {infile}'),
 | 
			
		||||
#)
 | 
			
		||||
# )
 | 
			
		||||
 | 
			
		||||
THUMBNAIL_PROCESSORS = (
 | 
			
		||||
    'easy_thumbnails.processors.colorspace',
 | 
			
		||||
| 
						 | 
				
			
			@ -446,14 +445,15 @@ AUTH_USER_MODEL = 'membership.CustomUser'
 | 
			
		|||
 | 
			
		||||
# PAYMENT
 | 
			
		||||
 | 
			
		||||
STRIPE_API_PUBLIC_KEY = 'pk_test_QqBZ50Am8KOxaAlOxbcm9Psl'  # used in frontend to call from user browser
 | 
			
		||||
STRIPE_API_PRIVATE_KEY = 'sk_test_dqAmbKAij12QCGfkYZ3poGt2'  # used in backend payment
 | 
			
		||||
STRIPE_DESCRIPTION_ON_PAYMENT = "Payment for ungleich GmbH services"
 | 
			
		||||
 | 
			
		||||
# EMAIL MESSAGES
 | 
			
		||||
REGISTRATION_MESSAGE = {'subject': "Validation mail",
 | 
			
		||||
                        'message': 'Please validate Your account under this link http://localhost:8000/en-us/validate/{}',
 | 
			
		||||
                        'from': 'test@test.com'}
 | 
			
		||||
                        'message': 'Thank You for registering for account on Digital Glarus.\nPlease verify Your account under following link http://{host}/en-us/digitalglarus/login/validate/{slug}',
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
STRIPE_API_PRIVATE_KEY = env('STRIPE_API_PRIVATE_KEY')
 | 
			
		||||
STRIPE_API_PUBLIC_KEY = env('STRIPE_API_PUBLIC_KEY')
 | 
			
		||||
 | 
			
		||||
DEBUG = True
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -461,5 +461,3 @@ if DEBUG:
 | 
			
		|||
    from .local import *
 | 
			
		||||
else:
 | 
			
		||||
    from .prod import *
 | 
			
		||||
#dont migrate test
 | 
			
		||||
# SOUTH_TESTS_MIGRATE = False
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,15 +1,9 @@
 | 
			
		|||
from .base import *
 | 
			
		||||
 | 
			
		||||
REGISTRATION_MESSAGE['message'] = REGISTRATION_MESSAGE['message'].format(host='dynamicweb-development.ungleich.ch',slug='{slug}')
 | 
			
		||||
ALLOWED_HOSTS = [
 | 
			
		||||
    "*"
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
# DATABASES = {
 | 
			
		||||
#     'default': {
 | 
			
		||||
#         'ENGINE': 'django.db.backends.sqlite3',
 | 
			
		||||
#         'NAME': 'app.db',
 | 
			
		||||
#     }
 | 
			
		||||
# }
 | 
			
		||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
 | 
			
		||||
 | 
			
		||||
CACHES = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,8 @@ ADMINS = (
 | 
			
		|||
 | 
			
		||||
MANAGERS = ADMINS
 | 
			
		||||
 | 
			
		||||
REGISTRATION_MESSAGE['message'] = REGISTRATION_MESSAGE['message'].format(host='digitalglarus.ungleich.ch',slug='{slug}')
 | 
			
		||||
 | 
			
		||||
ALLOWED_HOSTS = [
 | 
			
		||||
    ".ungleich.ch",
 | 
			
		||||
    "digital.glarus.ungleich.ch" ,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,12 +4,12 @@ from django.db import models
 | 
			
		|||
from django.utils.translation import ugettext_lazy as _
 | 
			
		||||
from django.contrib.auth.models import User, AbstractBaseUser, BaseUserManager, AbstractUser
 | 
			
		||||
from django.contrib.auth.hashers import make_password
 | 
			
		||||
from django.core.mail import send_mail
 | 
			
		||||
from django.core.validators import RegexValidator
 | 
			
		||||
from django.contrib.auth.models import User
 | 
			
		||||
from django.contrib.sites.models import Site
 | 
			
		||||
 | 
			
		||||
from utils.stripe_utils import StripeUtils
 | 
			
		||||
from utils.mailer import DigitalGlarusRegistrationMailer
 | 
			
		||||
 | 
			
		||||
REGISTRATION_MESSAGE = {'subject': "Validation mail",
 | 
			
		||||
                        'message': 'Please validate Your account under this link http://localhost:8000/en-us/digitalglarus/login/validate/{}',
 | 
			
		||||
| 
						 | 
				
			
			@ -72,9 +72,8 @@ class CustomUser(AbstractBaseUser):
 | 
			
		|||
        if not user:
 | 
			
		||||
            user = cls.objects.create_user(name=name, email=email, password=password)
 | 
			
		||||
            if user:
 | 
			
		||||
                send_mail(REGISTRATION_MESSAGE['subject'],
 | 
			
		||||
                          REGISTRATION_MESSAGE['message'].format(user.validation_slug),
 | 
			
		||||
                          REGISTRATION_MESSAGE['from'], [user.email], fail_silently=False)
 | 
			
		||||
                dg = DigitalGlarusRegistrationMailer(user.validation_slug)
 | 
			
		||||
                dg.send_mail(to=user.email)
 | 
			
		||||
                return user
 | 
			
		||||
            else:
 | 
			
		||||
                return None
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										52
									
								
								utils/mailer.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								utils/mailer.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,52 @@
 | 
			
		|||
import six
 | 
			
		||||
from django.core.mail import send_mail
 | 
			
		||||
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BaseMailer(object):
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        self._slug = None
 | 
			
		||||
        self.no_replay_mail = 'no-replay@ungleich.ch'
 | 
			
		||||
 | 
			
		||||
        if not hasattr(self, '_to'):
 | 
			
		||||
            self._to = None
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def slug(self):
 | 
			
		||||
        return self._slug
 | 
			
		||||
 | 
			
		||||
    @slug.setter
 | 
			
		||||
    def slug(self, val):
 | 
			
		||||
        assert isinstance(val, six.string_types), "slug is not string: %r" % val
 | 
			
		||||
        self._slug = val
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def registration(self):
 | 
			
		||||
        return self.message
 | 
			
		||||
 | 
			
		||||
    @registration.setter
 | 
			
		||||
    def registration(self, val):
 | 
			
		||||
        msg = "registration is not dict with fields subject,message"
 | 
			
		||||
        assert type(val) is dict, msg
 | 
			
		||||
        assert val.get('subject') and val.get('message'), msg
 | 
			
		||||
        self._message, self._subject, self._from = (
 | 
			
		||||
            val.get('message'), val.get('subject'), val.get('from'))
 | 
			
		||||
        assert isinstance(self.slug, six.string_types), 'slug not set'
 | 
			
		||||
 | 
			
		||||
    def send_mail(self, to=None):
 | 
			
		||||
        if not to:
 | 
			
		||||
            to = self._to
 | 
			
		||||
        if not self.message:
 | 
			
		||||
            raise NotImplementedError
 | 
			
		||||
        send_mail(self._subject, self._message, self.no_replay_mail, [to])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DigitalGlarusRegistrationMailer(BaseMailer):
 | 
			
		||||
    message = settings.REGISTRATION_MESSAGE
 | 
			
		||||
 | 
			
		||||
    def __init__(self, slug):
 | 
			
		||||
        self.slug = slug
 | 
			
		||||
        self.registration = self.message
 | 
			
		||||
        self._message = self._message.format(slug=self._slug)
 | 
			
		||||
        super().__init__()
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
import stripe
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
 | 
			
		||||
stripe.api_key = settings.STRIPE_API_PRIVATE_KEY
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -122,3 +121,6 @@ class StripeUtils(object):
 | 
			
		|||
            name=name,
 | 
			
		||||
            currency=self.CURRENCY,
 | 
			
		||||
            id=id)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue