mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-25 09:11:13 +00:00
Suppression des appels à la db de l'ancien site (#483)
This commit is contained in:
parent
f4d7fae8ca
commit
e0ad288cf4
@ -469,36 +469,6 @@ class User(AbstractBaseUser):
|
||||
else:
|
||||
create = True
|
||||
super(User, self).save(*args, **kwargs)
|
||||
if (
|
||||
create and settings.IS_OLD_MYSQL_PRESENT
|
||||
): # Create user on the old site: TODO remove me!
|
||||
import MySQLdb
|
||||
|
||||
try:
|
||||
db = MySQLdb.connect(**settings.OLD_MYSQL_INFOS)
|
||||
c = db.cursor()
|
||||
c.execute(
|
||||
"""INSERT INTO utilisateurs (id_utilisateur, nom_utl, prenom_utl, email_utl, hash_utl, ae_utl) VALUES
|
||||
(%s, %s, %s, %s, %s, %s)""",
|
||||
(
|
||||
self.id,
|
||||
self.last_name,
|
||||
self.first_name,
|
||||
self.email,
|
||||
"valid",
|
||||
"0",
|
||||
),
|
||||
)
|
||||
db.commit()
|
||||
except Exception as e:
|
||||
with open(settings.BASE_DIR + "/user_fail.log", "a") as f:
|
||||
print(
|
||||
"FAIL to add user %s (%s %s - %s) to old site"
|
||||
% (self.id, self.first_name, self.last_name, self.email),
|
||||
file=f,
|
||||
)
|
||||
print("Reason: %s" % (repr(e)), file=f)
|
||||
db.rollback()
|
||||
|
||||
def make_home(self):
|
||||
if self.home is None:
|
||||
|
1700
migrate.py
1700
migrate.py
File diff suppressed because it is too large
Load Diff
@ -35,13 +35,15 @@ For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/1.8/ref/settings/
|
||||
"""
|
||||
|
||||
import binascii
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
import os
|
||||
import sys
|
||||
import binascii
|
||||
|
||||
import sentry_sdk
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from sentry_sdk.integrations.django import DjangoIntegration
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
@ -59,7 +61,6 @@ INTERNAL_IPS = ["127.0.0.1"]
|
||||
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
||||
@ -199,7 +200,6 @@ WSGI_APPLICATION = "sith.wsgi.application"
|
||||
|
||||
REST_FRAMEWORK = {}
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
||||
|
||||
@ -210,7 +210,6 @@ DATABASES = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.8/topics/i18n/
|
||||
|
||||
@ -264,17 +263,6 @@ EMAIL_PORT = 25
|
||||
|
||||
# Below this line, only Sith-specific variables are defined
|
||||
|
||||
IS_OLD_MYSQL_PRESENT = False
|
||||
OLD_MYSQL_INFOS = {
|
||||
"host": "ae-db",
|
||||
"user": "my_user",
|
||||
"passwd": "password",
|
||||
"db": "ae2-db",
|
||||
"charset": "utf8",
|
||||
"use_unicode": True,
|
||||
}
|
||||
|
||||
|
||||
SITH_URL = "my.url.git.an"
|
||||
SITH_NAME = "Sith website"
|
||||
SITH_TWITTER = "@ae_utbm"
|
||||
@ -326,7 +314,6 @@ SITH_GROUP_SAS_ADMIN_ID = 11
|
||||
SITH_GROUP_FORUM_ADMIN_ID = 12
|
||||
SITH_GROUP_PEDAGOGY_ADMIN_ID = 13
|
||||
|
||||
|
||||
SITH_CLUB_REFOUND_ID = 89
|
||||
SITH_COUNTER_REFOUND_ID = 38
|
||||
SITH_PRODUCT_REFOUND_ID = 5
|
||||
|
@ -119,58 +119,6 @@ class Subscription(models.Model):
|
||||
from_email="ae@utbm.fr",
|
||||
)
|
||||
self.member.make_home()
|
||||
if settings.IS_OLD_MYSQL_PRESENT:
|
||||
import MySQLdb
|
||||
|
||||
try: # Create subscription on the old site: TODO remove me!
|
||||
LOCATION = {"SEVENANS": 5, "BELFORT": 6, "MONTBELIARD": 9, "EBOUTIC": 5}
|
||||
TYPE = {
|
||||
"un-semestre": 0,
|
||||
"deux-semestres": 1,
|
||||
"cursus-tronc-commun": 2,
|
||||
"cursus-branche": 3,
|
||||
"membre-honoraire": 4,
|
||||
"assidu": 5,
|
||||
"amicale/doceo": 6,
|
||||
"reseau-ut": 7,
|
||||
"crous": 8,
|
||||
"sbarro/esta": 9,
|
||||
"cursus-alternant": 10,
|
||||
"welcome-semestre": 11,
|
||||
"deux-mois-essai": 12,
|
||||
}
|
||||
PAYMENT = {
|
||||
"CHECK": 1,
|
||||
"CARD": 2,
|
||||
"CASH": 3,
|
||||
"OTHER": 4,
|
||||
"EBOUTIC": 5,
|
||||
"OTHER": 0,
|
||||
}
|
||||
|
||||
db = MySQLdb.connect(**settings.OLD_MYSQL_INFOS)
|
||||
c = db.cursor()
|
||||
c.execute(
|
||||
"""INSERT INTO ae_cotisations (id_utilisateur, date_cotis, date_fin_cotis, mode_paiement_cotis,
|
||||
type_cotis, id_comptoir) VALUES (%s, %s, %s, %s, %s, %s)""",
|
||||
(
|
||||
self.member.id,
|
||||
self.subscription_start,
|
||||
self.subscription_end,
|
||||
PAYMENT[self.payment_method],
|
||||
TYPE[self.subscription_type],
|
||||
LOCATION[self.location],
|
||||
),
|
||||
)
|
||||
db.commit()
|
||||
except Exception as e:
|
||||
with open(settings.BASE_DIR + "/subscription_fail.log", "a") as f:
|
||||
print(
|
||||
"FAIL to add subscription to %s to old site" % (self.member),
|
||||
file=f,
|
||||
)
|
||||
print("Reason: %s" % (repr(e)), file=f)
|
||||
db.rollback()
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("core:user_edit", kwargs={"user_id": self.member.pk})
|
||||
|
Loading…
Reference in New Issue
Block a user