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