Add vite react #45

Closed
lukas wants to merge 42 commits from add-frontend into main
5 changed files with 18 additions and 30 deletions
Showing only changes of commit 850ca382ad - Show all commits

View File

@ -1,5 +1,6 @@
## Unreleased
* Add wikidata ID and year for editions
* Allow filtering by game, edition, purchase from the session list
* Add icons for the above

View File

@ -14,7 +14,7 @@ textarea {
#session-table {
display: grid;
grid-template-columns: 3fr repeat(3, 1fr) 0.5fr 1fr;
grid-template-columns: 3fr 2fr repeat(2, 1fr) 0.5fr 1fr;
}
.purchase-name > span:nth-child(2) {

View File

@ -147,7 +147,7 @@ class EditionForm(forms.ModelForm):
class Meta:
model = Edition
fields = ["game", "name", "sort_name", "platform", "year_released", "wikidata"]
fields = ["game", "name", "platform", "year_released", "wikidata"]
class GameForm(forms.ModelForm):

View File

@ -38,13 +38,9 @@ class Edition(models.Model):
game = models.ForeignKey("Game", on_delete=models.CASCADE)
name = models.CharField(max_length=255)
sort_name = models.CharField(max_length=255, null=True, blank=True, default=None)
platform = models.ForeignKey(
"Platform", on_delete=models.CASCADE, null=True, blank=True, default=None
)
year_released = models.IntegerField(null=True, blank=True, default=None)
platform = models.ForeignKey("Platform", on_delete=models.CASCADE)
year_released = models.IntegerField(default=datetime.today().year)
wikidata = models.CharField(max_length=50, null=True, blank=True, default=None)
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.sort_name
@ -134,27 +130,10 @@ class Purchase(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
additional_info = [
self.get_type_display() if self.type != Purchase.GAME else "",
f"{self.edition.platform} version on {self.platform}"
if self.platform != self.edition.platform
else self.platform,
self.edition.year_released,
self.get_ownership_type_display(),
]
return f"{self.edition} ({', '.join(filter(None, map(str, additional_info)))})"
def is_game(self):
return self.type == self.GAME
def save(self, *args, **kwargs):
if self.type == Purchase.GAME:
self.name = ""
elif self.type != Purchase.GAME and not self.related_purchase:
raise ValidationError(
f"{self.get_type_display()} must have a related purchase."
)
super().save(*args, **kwargs)
platform_info = self.platform
if self.platform != self.edition.platform:
platform_info = f"{self.edition.platform} version on {self.platform}"
return f"{self.edition} ({platform_info}, {self.edition.year_released}, {self.get_ownership_type_display()})"
class Platform(models.Model):

View File

@ -55,7 +55,15 @@
</a>
</span>
</div>
<div class="dark:text-white overflow-hidden text-ellipsis whitespace-nowrap"><a class="hover:underline" href="{% url 'list_sessions_by_platform' data.purchase.platform.id %}">{{ data.purchase.platform }}</a></div>
<div class="dark:text-white overflow-hidden text-ellipsis whitespace-nowrap">
<a class="hover:underline" href="{% url 'list_sessions_by_platform' data.purchase.platform.id %}">
{% if data.purchase.platform != data.purchase.edition.platform %}
{{data.purchase.edition.platform}} on {{ data.purchase.platform }}
{% else %}
{{ data.purchase.platform }}
{% endif %}
</a>
</div>
<div class="dark:text-slate-400 text-center">{{ data.timestamp_start | date:"d/m/Y H:i" }}</div>
<div class="dark:text-slate-400 text-center">
{% if data.unfinished %}