Closed liusiqi43 closed 9 years ago
After further research on the subject, i found the function that calculate this value on rezo.rez. However, there is no clean interface being provided.
So the question is wether to add the interface we need to rezo.rez or to recalculate the value on our side
Adding the interface will be worse than anything even if I agree with the fact it will keep consistency. This is mostly due to a bad database design as this value should be saved with the user record.
To me, the best solution is to (re)implement the calculation function in the User object as a cached_property (see rezo/models.py file).
If you want to do this quickly, I can tweak rezo.rez pages/quotasDetail/IP page to output this data in an easy to parse format (rather than HTML…) since I don't think it is no longer in use (without paiji1).
Even if it is not maybe the cleanest way to do it, I prefer using rezo.rez to get all needed data about members rather than using a direct DB access that will be dependent on rezo.rez DB structure.
Actually we already have the abstraction layer implemented (I used the command inspectdb). So technically we already have the interface required to hit the rezo.rez DB. Only for now a large part of it is commented and need to be rewritten to properly implement associations (IntegerField -> ForeignKey, english naming conventions). See this file:
https://github.com/rezometz/paiji2/blob/master/rezo/models.py
I would like to avoid an API request and prefer to hit the DB. Actually the API solution will involve more work (my development environment is set up with a local rezo.rez DB clone).
The best way to go is to add a new method named expire_on to the Utilisateur object that implements it (using also cached_property decorator). In the future if we want to add a expire_on field to rezo.rez, migration will be easier (no need to change anything in templates).
FYI, the account used by Paiji for the rezo.rez DB is a read-only one.
The problem here is that there is no clear bdd entry for that data. We need to use the interface apparently provided by rezo.rez