Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: remove unused codes #347

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/product_management/migrations/0052_delete_productchallenge.py
Original file line number Diff line number Diff line change
@@ -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",
),
]
88 changes: 1 addition & 87 deletions apps/product_management/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading