diff --git a/apps/product_management/migrations/0052_delete_productchallenge.py b/apps/product_management/migrations/0052_delete_productchallenge.py new file mode 100644 index 00000000..a13cbb15 --- /dev/null +++ b/apps/product_management/migrations/0052_delete_productchallenge.py @@ -0,0 +1,16 @@ +# Generated by Django 4.2.2 on 2024-07-12 20:27 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("product_management", "0051_remove_challenge_tag_delete_tag"), + ] + + operations = [ + migrations.DeleteModel( + name="ProductChallenge", + ), + ] diff --git a/apps/product_management/models.py b/apps/product_management/models.py index 1ce2ee8b..cc1cc38a 100644 --- a/apps/product_management/models.py +++ b/apps/product_management/models.py @@ -2,7 +2,7 @@ from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models -from django.db.models.signals import post_save, pre_save +from django.db.models.signals import pre_save from django.dispatch import receiver from django.urls import reverse from django.utils.text import slugify @@ -135,35 +135,6 @@ def get_completed_challenges_count(self): def get_challenge_tags(self): return Challenge.objects.filter(task_tags__initiative=self).distinct("id").all() - @staticmethod - def get_filtered_data(input_data, filter_data=None, exclude_data=None): - if filter_data is None: - filter_data = {} - if not filter_data: - filter_data = dict() - - if not input_data: - input_data = dict() - - statuses = input_data.get("statuses", []) - tags = input_data.get("tags", []) - categories = input_data.get("categories", None) - - if statuses: - filter_data["status__in"] = statuses - - if tags: - filter_data["challenge__tag__in"] = tags - - if categories: - filter_data["challenge__category__parent__in"] = categories - - queryset = Initiative.objects.filter(**filter_data) - if exclude_data: - queryset = queryset.exclude(**exclude_data) - - return queryset.distinct("id").all() - class Challenge(TimeStampMixin, UUIDMixin, common.AttachmentAbstract): class ChallengeStatus(models.TextChoices): @@ -281,47 +252,6 @@ def get_bounty_points(self): return total - @staticmethod - def get_filtered_data(input_data, filter_data=None, exclude_data=None): - if not filter_data: - filter_data = {} - - if not input_data: - input_data = {} - - sorted_by = input_data.get("sorted_by", "title") - statuses = input_data.get("statuses", []) - tags = input_data.get("tags", []) - priority = input_data.get("priority", []) - assignee = input_data.get("assignee", []) - task_creator = input_data.get("task_creator", []) - skills = input_data.get("skils", []) - - if statuses: - filter_data["status__in"] = statuses - - if tags: - filter_data["tag__in"] = tags - - if priority: - filter_data["priority__in"] = priority - - if task_creator: - filter_data["created_by__in"] = task_creator - - if assignee: - filter_data["bountyclaim__status__in"] = [0, 1] - filter_data["bountyclaim__person_id__in"] = assignee - - if skills: - filter_data["skill__parent__in"] = skills - - queryset = Challenge.objects.filter(**filter_data) - if exclude_data: - queryset = queryset.exclude(**exclude_data) - - return queryset.order_by(sorted_by).all() - def get_short_description(self): # return a shortened version of the description text MAX_LEN = 90 @@ -398,22 +328,6 @@ class Meta: db_table = "product_management_challenge_dependencies" -class ProductChallenge(TimeStampMixin, UUIDMixin): - product = models.ForeignKey(Product, on_delete=models.CASCADE) - challenge = models.ForeignKey(Challenge, on_delete=models.CASCADE) - - -@receiver(post_save, sender=ProductChallenge) -def save_product_task(sender, instance, created, **kwargs): - if created: - challenge = instance.challenge - last_product_challenge = ( - Challenge.objects.filter(productchallenge__product=instance.product).order_by("-published_id").first() - ) - challenge.published_id = last_product_challenge.published_id + 1 if last_product_challenge else 1 - challenge.save() - - class ContributorGuide(models.Model): product = models.ForeignKey( to=Product,