diff --git a/website/migrations/0126_remove_sizzle_issue_user_and_more.py b/website/migrations/0126_remove_sizzle_issue_user_and_more.py new file mode 100644 index 000000000..52d0d2daf --- /dev/null +++ b/website/migrations/0126_remove_sizzle_issue_user_and_more.py @@ -0,0 +1,138 @@ +# Generated by Django 5.0.7 on 2024-08-09 18:52 + +import django.db.models.deletion +import django.utils.timezone +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("website", "0125_sizzle_issue_sizzle_activitylog_sizzle_screenshot_and_more"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.RemoveField( + model_name="sizzle_issue", + name="user", + ), + migrations.RemoveField( + model_name="sizzle_screenshot", + name="issue", + ), + migrations.RemoveField( + model_name="sizzle_timelog", + name="issue", + ), + migrations.RemoveField( + model_name="sizzle_screenshot", + name="user", + ), + migrations.RemoveField( + model_name="sizzle_timelog", + name="user", + ), + migrations.AddField( + model_name="issuescreenshot", + name="is_activity_screenshot", + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name="issue", + name="created", + field=models.DateTimeField( + default=django.utils.timezone.now, editable=False + ), + ), + migrations.CreateModel( + name="ActivityLog", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("window_title", models.CharField(max_length=255)), + ("recorded_at", models.DateTimeField(auto_now_add=True)), + ( + "created", + models.DateTimeField( + default=django.utils.timezone.now, editable=False + ), + ), + ( + "issue", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="activity_logs", + to="website.issue", + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="activity_logs", + to=settings.AUTH_USER_MODEL, + ), + ), + ], + ), + migrations.CreateModel( + name="TimeLog", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("start_time", models.DateTimeField()), + ("end_time", models.DateTimeField(blank=True, null=True)), + ("duration", models.DurationField(blank=True, null=True)), + ( + "created", + models.DateTimeField( + default=django.utils.timezone.now, editable=False + ), + ), + ( + "issue", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="timelogs", + to="website.issue", + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="timelogs", + to=settings.AUTH_USER_MODEL, + ), + ), + ], + ), + migrations.DeleteModel( + name="Sizzle_ActivityLog", + ), + migrations.DeleteModel( + name="Sizzle_Issue", + ), + migrations.DeleteModel( + name="Sizzle_Screenshot", + ), + migrations.DeleteModel( + name="Sizzle_TimeLog", + ), + ] diff --git a/website/models.py b/website/models.py index c21d0dbde..b804ce0d1 100644 --- a/website/models.py +++ b/website/models.py @@ -13,7 +13,7 @@ from django.core.exceptions import MultipleObjectsReturned, ValidationError from django.core.files.base import ContentFile from django.core.files.storage import default_storage -from django.core.validators import MinLengthValidator, URLValidator +from django.core.validators import URLValidator from django.db import models from django.db.models import Count from django.db.models.signals import post_delete, post_save @@ -280,6 +280,7 @@ class Issue(models.Model): cve_id = models.CharField(max_length=16, null=True, blank=True) cve_score = models.DecimalField(max_digits=2, decimal_places=1, null=True, blank=True) tags = models.ManyToManyField(Tag, blank=True) + created = models.DateTimeField(default=timezone.now, editable=False) def __unicode__(self): return self.description @@ -388,6 +389,7 @@ def delete_image_on_issue_delete(sender, instance, **kwargs): class IssueScreenshot(models.Model): image = models.ImageField(upload_to="screenshots", validators=[validate_image]) issue = models.ForeignKey(Issue, on_delete=models.CASCADE, related_name="screenshots") + is_activity_screenshot = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) @@ -788,36 +790,15 @@ def __str__(self): return f"{self.user.username} - {self.amount} BACON" -class Sizzle_Issue(models.Model): - github_issue_id = models.CharField( - max_length=100, unique=True, validators=[MinLengthValidator(1)] - ) - title = models.CharField(max_length=255, blank=False) - description = models.TextField(blank=True) - url = models.URLField(validators=[URLValidator()]) - status = models.CharField(max_length=100) - user = models.ForeignKey( - settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="sizzle_issues" - ) - - class Meta: - indexes = [ - models.Index(fields=["github_issue_id"]), - models.Index(fields=["user"]), - ] - - def __str__(self): - return f"Issue {self.github_issue_id}: {self.title}" - - -class Sizzle_TimeLog(models.Model): - issue = models.ForeignKey(Sizzle_Issue, on_delete=models.CASCADE, related_name="timelogs") +class TimeLog(models.Model): + issue = models.ForeignKey(Issue, on_delete=models.CASCADE, related_name="timelogs") user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="timelogs" ) start_time = models.DateTimeField() end_time = models.DateTimeField(null=True, blank=True) duration = models.DurationField(null=True, blank=True) + created = models.DateTimeField(default=timezone.now, editable=False) def save(self, *args, **kwargs): if self.end_time and self.start_time <= self.end_time: @@ -828,25 +809,14 @@ def __str__(self): return f"TimeLog for {self.issue.title} by {self.user.username} from {self.start_time} to {self.end_time}" -class Sizzle_ActivityLog(models.Model): - issue = models.ForeignKey(Sizzle_Issue, on_delete=models.CASCADE, related_name="activity_logs") +class ActivityLog(models.Model): + issue = models.ForeignKey(Issue, on_delete=models.CASCADE, related_name="activity_logs") user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="activity_logs" ) window_title = models.CharField(max_length=255) recorded_at = models.DateTimeField(auto_now_add=True) + created = models.DateTimeField(default=timezone.now, editable=False) def __str__(self): return f"{self.issue.title} - {self.window_title} at {self.recorded_at}" - - -class Sizzle_Screenshot(models.Model): - issue = models.ForeignKey(Sizzle_Issue, on_delete=models.CASCADE, related_name="screenshots") - user = models.ForeignKey( - settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="screenshots" - ) - filename = models.CharField(max_length=255) - timestamp = models.DateTimeField(auto_now_add=True) - - def __str__(self): - return f"{self.issue.title} - Screenshot at {self.timestamp}"