diff options
| author | 2019-09-30 15:17:03 +0200 | |
|---|---|---|
| committer | 2019-09-30 15:42:16 +0200 | |
| commit | 9b38f42272994350a6bb58da796dcca86ee628d9 (patch) | |
| tree | 853f4cee539bef70bc52367651f4e8f3bc6e09fb /pydis_site/apps/api/models/bot | |
| parent | Merge pull request #261 from python-discord/decoupling-warnings-and-notes (diff) | |
Migrate nominations to new Nomination model
Before the migration to Django, we stored meta data on a nomination,
such as the `reason` and `end_reason`, in the infraction table using
"note" infractions, using a special prefix for the `reason`.
We have since decided to move nominations out of the infraction
context by creating a special `Nomination` model. However, given the
complexity of the data migration, we did not yet migrate the old
nomination data to this new model. This commit migrates that data by performing a data migration.
The data migration works as follows:
- Query all nomination data in chronological order;
- Replay all nominations and add them to the `Nomination` model;
- Delete the now obsolete `Infraction` entry.
In addition, this commit also adds a useful string representation for
`Nomination` objects.
Diffstat (limited to 'pydis_site/apps/api/models/bot')
| -rw-r--r-- | pydis_site/apps/api/models/bot/nomination.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pydis_site/apps/api/models/bot/nomination.py b/pydis_site/apps/api/models/bot/nomination.py index 8a8f4d36..cd9951aa 100644 --- a/pydis_site/apps/api/models/bot/nomination.py +++ b/pydis_site/apps/api/models/bot/nomination.py @@ -39,3 +39,8 @@ class Nomination(ModelReprMixin, models.Model): help_text="When the nomination was ended.", null=True ) + + def __str__(self): + """Representation that makes the target and state of the nomination immediately evident.""" + status = "active" if self.active else "ended" + return f"Nomination of {self.user} ({status})" |