country fix
This commit is contained in:
@@ -46,17 +46,19 @@ class OfficeCountryService(BaseService):
|
|||||||
val_type = data.get('val_type', '')
|
val_type = data.get('val_type', '')
|
||||||
country_uid = data.get('country_uid', '')
|
country_uid = data.get('country_uid', '')
|
||||||
code = data.get('code', '')
|
code = data.get('code', '')
|
||||||
val = data.get('val', '')
|
val = data.get('val', 0)
|
||||||
country_result=[]
|
country_result=[]
|
||||||
if val_type == 'STATUS':
|
with db.session.begin():
|
||||||
country_result = Country.set_country_status(country_uid, code, val)
|
if val_type == 'STATUS':
|
||||||
|
country_result = Country.set_country_status(country_uid, code, val)
|
||||||
|
|
||||||
if val_type == 'SIGNUP':
|
if val_type == 'SIGNUP':
|
||||||
country_result = Country.set_country_signup(country_uid, code, val)
|
country_result = Country.set_country_signup(country_uid, code, val)
|
||||||
|
|
||||||
|
|
||||||
account_result = {
|
account_result = {
|
||||||
"set_country_data":country_result,
|
"set_country_data":country_result.id,
|
||||||
|
"value": val,
|
||||||
"message": "Updated"
|
"message": "Updated"
|
||||||
}
|
}
|
||||||
logger.info('RETURN API::get office account view')
|
logger.info('RETURN API::get office account view')
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ from datetime import datetime, timezone, timedelta
|
|||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from sqlalchemy.sql import func
|
from sqlalchemy.sql import func
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Country(db.Model):
|
class Country(db.Model):
|
||||||
__tablename__ = 'country'
|
__tablename__ = 'country'
|
||||||
@@ -24,25 +25,28 @@ class Country(db.Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_all_countries(cls):
|
def get_all_countries(cls):
|
||||||
country_list = cls.query.all()
|
country_list = cls.query.order_by(cls.description.asc()).all()
|
||||||
if not country_list:
|
if not country_list:
|
||||||
return None
|
return None
|
||||||
return country_list
|
return country_list
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_country_status(cls, country_uid, code, val):
|
def set_country_status(cls, country_uid, code, val):
|
||||||
|
logger.info(f" Data for set_country_status Data {country_uid} ,{code} {val}")
|
||||||
country_data = cls.query.filter_by(uid=str(country_uid), code=str(code)).first()
|
country_data = cls.query.filter_by(uid=str(country_uid), code=str(code)).first()
|
||||||
if not country_data:
|
if not country_data:
|
||||||
return None
|
return None
|
||||||
country_data.status = val
|
logger.info("UPDT::")
|
||||||
|
country_data.status = int(val)
|
||||||
return country_data
|
return country_data
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_country_signup(cls, country_uid, code, val):
|
def set_country_signup(cls, country_uid, code, val):
|
||||||
|
logger.info(f" Data for set_country_signup Data {country_uid} ,{code} {val}")
|
||||||
country_data = cls.query.filter_by(uid=str(country_uid), code=str(code)).first()
|
country_data = cls.query.filter_by(uid=str(country_uid), code=str(code)).first()
|
||||||
if not country_data:
|
if not country_data:
|
||||||
return None
|
return None
|
||||||
|
logger.info("UPDT::")
|
||||||
country_data.signup = val
|
country_data.signup = val
|
||||||
return country_data
|
return country_data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user