diff --git a/website/admin.py b/website/admin.py index d871d8435..cd737bd4b 100644 --- a/website/admin.py +++ b/website/admin.py @@ -24,6 +24,7 @@ Subscription, Suggestion, SuggestionVotes, + Tag, Transaction, UserProfile, Wallet, @@ -345,3 +346,4 @@ class ProjectAdmin(admin.ModelAdmin): admin.site.register(IP, IPAdmin) admin.site.register(Transaction) admin.site.register(Monitor, MonitorAdmin) +admin.site.register(Tag) diff --git a/website/migrations/0123_tag_issue_tags.py b/website/migrations/0123_tag_issue_tags.py new file mode 100644 index 000000000..0ad376ed0 --- /dev/null +++ b/website/migrations/0123_tag_issue_tags.py @@ -0,0 +1,32 @@ +# Generated by Django 5.0.7 on 2024-08-06 07:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("website", "0122_rename_user_agent_string_ip_agent"), + ] + + operations = [ + migrations.CreateModel( + name="Tag", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=255)), + ], + ), + migrations.AddField( + model_name="issue", + name="tags", + field=models.ManyToManyField(blank=True, related_name="tags", to="website.tag"), + ), + ] diff --git a/website/migrations/0124_company_tags_domain_tags_project_tags_and_more.py b/website/migrations/0124_company_tags_domain_tags_project_tags_and_more.py new file mode 100644 index 000000000..835731fda --- /dev/null +++ b/website/migrations/0124_company_tags_domain_tags_project_tags_and_more.py @@ -0,0 +1,37 @@ +# Generated by Django 5.0.7 on 2024-08-06 15:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("website", "0123_tag_issue_tags"), + ] + + operations = [ + migrations.AddField( + model_name="company", + name="tags", + field=models.ManyToManyField(blank=True, to="website.tag"), + ), + migrations.AddField( + model_name="domain", + name="tags", + field=models.ManyToManyField(blank=True, to="website.tag"), + ), + migrations.AddField( + model_name="project", + name="tags", + field=models.ManyToManyField(blank=True, to="website.tag"), + ), + migrations.AddField( + model_name="userprofile", + name="tags", + field=models.ManyToManyField(blank=True, to="website.tag"), + ), + migrations.AlterField( + model_name="issue", + name="tags", + field=models.ManyToManyField(blank=True, to="website.tag"), + ), + ] diff --git a/website/models.py b/website/models.py index 6074b41fa..20b998ba5 100644 --- a/website/models.py +++ b/website/models.py @@ -44,6 +44,13 @@ class Subscription(models.Model): created = models.DateTimeField(auto_now_add=True) +class Tag(models.Model): + name = models.CharField(max_length=255) + + def __str__(self): + return self.name + + class Company(models.Model): admin = models.ForeignKey(User, null=True, blank=True, on_delete=models.CASCADE) managers = models.ManyToManyField(User, related_name="user_companies") @@ -58,6 +65,7 @@ class Company(models.Model): modified = models.DateTimeField(auto_now=True) subscription = models.ForeignKey(Subscription, null=True, blank=True, on_delete=models.CASCADE) is_active = models.BooleanField(default=False) + tags = models.ManyToManyField(Tag, blank=True) def __str__(self): return self.name @@ -79,6 +87,7 @@ class Domain(models.Model): facebook = models.URLField(null=True, blank=True) created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) + tags = models.ManyToManyField(Tag, blank=True) def __unicode__(self): return self.name @@ -270,6 +279,7 @@ class Issue(models.Model): reporter_ip_address = models.GenericIPAddressField(null=True, blank=True) 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) def __unicode__(self): return self.description @@ -502,6 +512,7 @@ class UserProfile(models.Model): bch_address = models.CharField(max_length=100, blank=True, null=True) eth_address = models.CharField(max_length=100, blank=True, null=True) created = models.DateTimeField(auto_now_add=True) + tags = models.ManyToManyField(Tag, blank=True) def avatar(self, size=36): if self.user_avatar: @@ -714,6 +725,7 @@ class Project(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) contributors = models.ManyToManyField(Contributor, related_name="projects", blank=True) + tags = models.ManyToManyField(Tag, blank=True) def __str__(self): return self.name diff --git a/website/serializers.py b/website/serializers.py index 5211cefa5..c84a79a3b 100644 --- a/website/serializers.py +++ b/website/serializers.py @@ -10,6 +10,7 @@ Issue, Points, Project, + Tag, User, UserProfile, ) @@ -67,6 +68,12 @@ class Meta: ) +class TagSerializer(serializers.ModelSerializer): + class Meta: + model = Tag + fields = "__all__" + + class IssueSerializer(serializers.ModelSerializer): """ Serializer for Issue Model