Fixed old database bug in dev env

This commit is contained in:
Antoine Bartuccio 2016-09-02 21:24:10 +02:00
parent c5fd9d0076
commit 8328e668bd
3 changed files with 51 additions and 43 deletions

View File

@ -240,7 +240,7 @@ class User(AbstractBaseUser):
else: else:
create = True create = True
super(User, self).save(*args, **kwargs) super(User, self).save(*args, **kwargs)
if create: # Create user on the old site: TODO remove me! if create and settings.IS_OLD_MYSQL_PRESENT: # Create user on the old site: TODO remove me!
import MySQLdb import MySQLdb
try: try:
db = MySQLdb.connect(**settings.OLD_MYSQL_INFOS) db = MySQLdb.connect(**settings.OLD_MYSQL_INFOS)

View File

@ -17,6 +17,12 @@ from django.utils.translation import ugettext_lazy as _
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEV_ENV = True
if (DEV_ENV):
os.environ['HTTPS'] = "off"
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
else:
os.environ['HTTPS'] = "on" os.environ['HTTPS'] = "on"
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
@ -408,6 +414,7 @@ SITH_LAUNDERETTE_PRICES = {
'DRYING': 0.75, 'DRYING': 0.75,
} }
IS_OLD_MYSQL_PRESENT = False
OLD_MYSQL_INFOS = { OLD_MYSQL_INFOS = {
'host': 'ae-db', 'host': 'ae-db',
'user': "my_user", 'user': "my_user",

View File

@ -33,7 +33,7 @@ class Subscriber(User):
if not self.id: if not self.id:
create = True create = True
super(Subscriber, self).save() super(Subscriber, self).save()
if create: if create and settings.IS_OLD_MYSQL_PRESENT:
try: # Create user on the old site: TODO remove me! try: # Create user on the old site: TODO remove me!
db = MySQLdb.connect(**settings.OLD_MYSQL_INFOS) db = MySQLdb.connect(**settings.OLD_MYSQL_INFOS)
c = db.cursor() c = db.cursor()
@ -82,6 +82,7 @@ class Subscription(models.Model):
form.save(use_https=True, email_template_name='core/new_user_email.jinja', form.save(use_https=True, email_template_name='core/new_user_email.jinja',
subject_template_name='core/new_user_email_subject.jinja', from_email="ae@utbm.fr") subject_template_name='core/new_user_email_subject.jinja', from_email="ae@utbm.fr")
self.member.make_home() self.member.make_home()
if settings.IS_OLD_MYSQL_PRESENT:
try: # Create subscription on the old site: TODO remove me! try: # Create subscription on the old site: TODO remove me!
LOCATION = { LOCATION = {
"SEVENANS": 5, "SEVENANS": 5,