Commit 254fab6f authored by BAIRE Anthony's avatar BAIRE Anthony

Change Tos.version into a string

because the decimal format is kind of messy, especially we have:
1.01 != 1.1 and 1.1 == 1.10

Tos.version is now a CharField. For ordering, we use Tos.id instead
(the latest tos is the one with highest id).
parent d0c51abe
Pipeline #54099 failed with stage
in 1 minute and 12 seconds
......@@ -619,9 +619,13 @@ class Tos(BaseModel):
look for the latest version in the model. Check the view if you have any
doubt.
NOTE: ToS versions are ordered by Tos.id (not Tos.version), because
comparing version numbers with MySQL is quite a messy job. The latest ToS
is the one with the highest id.
"""
url = models.URLField(blank=True)
version = models.DecimalField(default=1.0, decimal_places=2, max_digits=6)
version = models.CharField(unique=True, max_length=32)
def __str__(self):
return str(self.version)
......@@ -629,7 +633,7 @@ class Tos(BaseModel):
@classmethod
def get_latest(cls):
"""Get the most up-to-date Terms of Service"""
return Tos.objects.order_by("-version").first()
return Tos.objects.order_by("-id").first()
class Meta:
db_table = "dj_tos"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment