Song reporting and user stats

This commit is contained in:
Olaf Slomp
2018-12-14 16:59:44 +01:00
committed by Daan Sprenkels
parent 0c1f9cb08d
commit f6fcc63450
17 changed files with 381 additions and 47 deletions

View File

@ -35,5 +35,27 @@ class Song(models.Model):
db_index=True,
help_text='hide this song from the search listings')
def report(self, user, note):
report_note = ReportNote(song=self, user=user, note=note)
report_note.save()
def __str__(self):
return self.artist + ' - ' + self.title
class ReportNote(models.Model):
song = models.ForeignKey(Song,
on_delete=models.CASCADE,
blank=False,
null=False,
db_index=True)
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
blank=True,
null=True,
db_index=True)
note = models.TextField(verbose_name='reason', blank=True,
help_text='reason for edit request')
def __str__(self):
return "{song.artist} - {song.title}: '{note}'".format(song=self.song, note=self.note)