07.01.26
This commit is contained in:
@@ -155,7 +155,7 @@ class Party(metaclass=PoolMeta):
|
|||||||
if overdue > 0:
|
if overdue > 0:
|
||||||
# scale by overdue relative to limit
|
# scale by overdue relative to limit
|
||||||
limit = self.credit_limit or 1
|
limit = self.credit_limit or 1
|
||||||
score += int(min(40, (overdue / float(limit)) * 100))
|
score += int(min(40, (float(overdue) / float(limit)) * 100))
|
||||||
|
|
||||||
# cap
|
# cap
|
||||||
if score > 100:
|
if score > 100:
|
||||||
|
|||||||
@@ -551,12 +551,14 @@ class Dashboard(ModelSQL, ModelView):
|
|||||||
return pu
|
return pu
|
||||||
|
|
||||||
def gen_url(self,name=None):
|
def gen_url(self,name=None):
|
||||||
|
Configuration = Pool().get('gr.configuration')
|
||||||
|
config = Configuration.search(['id','>',0])[0]
|
||||||
payload = {
|
payload = {
|
||||||
"resource": {"dashboard": self.bi_id},
|
"resource": {"dashboard": self.bi_id},
|
||||||
"params": {},
|
"params": {},
|
||||||
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=30),
|
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=30),
|
||||||
}
|
}
|
||||||
token = jwt.encode(payload, "798f256d3119a3292bf121196c2a38dddf2cad155c0b6b0b444efc34c6db197c", algorithm="HS256")
|
token = jwt.encode(payload, config.payload, algorithm="HS256")
|
||||||
logger.info("TOKEN:%s",token)
|
logger.info("TOKEN:%s",token)
|
||||||
return f"metabase:http://vps107.geneva.hosting:3000/embed/dashboard/{token}#bordered=true&titled=true"
|
return f"metabase:http://vps107.geneva.hosting:3000/embed/dashboard/{token}#bordered=true&titled=true"
|
||||||
|
|
||||||
|
|||||||
@@ -385,11 +385,11 @@ class ForexBI(ModelSingleton,ModelSQL, ModelView):
|
|||||||
config = Configuration.search(['id','>',0])[0]
|
config = Configuration.search(['id','>',0])[0]
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"resource": {"dashboard": 3},
|
"resource": {"dashboard": config.forex_id},
|
||||||
"params": {},
|
"params": {},
|
||||||
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=30),
|
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=30),
|
||||||
}
|
}
|
||||||
token = jwt.encode(payload, "798f256d3119a3292bf121196c2a38dddf2cad155c0b6b0b444efc34c6db197c", algorithm="HS256")
|
token = jwt.encode(payload, config.payload, algorithm="HS256")
|
||||||
logger.info("TOKEN:%s",token)
|
logger.info("TOKEN:%s",token)
|
||||||
if config.dark:
|
if config.dark:
|
||||||
url = f"metabase:{config.bi}/embed/dashboard/{token}#theme=night&bordered=true&titled=true"
|
url = f"metabase:{config.bi}/embed/dashboard/{token}#theme=night&bordered=true&titled=true"
|
||||||
|
|||||||
@@ -13,4 +13,7 @@ class GRConfiguration(ModelSingleton, ModelSQL, ModelView):
|
|||||||
|
|
||||||
bi = fields.Char("BI connexion")
|
bi = fields.Char("BI connexion")
|
||||||
dashboard = fields.Char("Dashboard connexion")
|
dashboard = fields.Char("Dashboard connexion")
|
||||||
dark = fields.Boolean("Dark mode")
|
dark = fields.Boolean("Dark mode")
|
||||||
|
pnl_id = fields.Integer("Pnl ID")
|
||||||
|
forex_id = fields.Integer("Forex ID")
|
||||||
|
payload = fields.Char("Metabase payload")
|
||||||
@@ -1011,11 +1011,11 @@ class PnlBI(ModelSingleton,ModelSQL, ModelView):
|
|||||||
config = Configuration.search(['id','>',0])[0]
|
config = Configuration.search(['id','>',0])[0]
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"resource": {"dashboard": 2},
|
"resource": {"dashboard": config.pnl_id},
|
||||||
"params": {},
|
"params": {},
|
||||||
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=30),
|
"exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=30),
|
||||||
}
|
}
|
||||||
token = jwt.encode(payload, "5d95b70853af02897d1240e2ee4834e2bf065a5132b5d09840fbef6cf683ae45", algorithm="HS256")
|
token = jwt.encode(payload, config.payload, algorithm="HS256")
|
||||||
logger.info("TOKEN:%s",token)
|
logger.info("TOKEN:%s",token)
|
||||||
if config.dark:
|
if config.dark:
|
||||||
url = f"metabase:{config.bi}/embed/dashboard/{token}#theme=night&bordered=true&titled=true"
|
url = f"metabase:{config.bi}/embed/dashboard/{token}#theme=night&bordered=true&titled=true"
|
||||||
|
|||||||
@@ -5,4 +5,10 @@
|
|||||||
<field name="dashboard"/>
|
<field name="dashboard"/>
|
||||||
<label name="dark"/>
|
<label name="dark"/>
|
||||||
<field name="dark"/>
|
<field name="dark"/>
|
||||||
|
<label name="pnl_id"/>
|
||||||
|
<field name="pnl_id"/>
|
||||||
|
<label name="forex_id"/>
|
||||||
|
<field name="forex_id"/>
|
||||||
|
<label name="payload"/>
|
||||||
|
<field name="payload"/>
|
||||||
</form>
|
</form>
|
||||||
Reference in New Issue
Block a user