Skip to content

Commit

Permalink
Add submit_status to note and summary
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezaAsadi2018 committed Sep 21, 2024
1 parent 1981d79 commit 744011f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils.translation import gettext_lazy as _


class MerlinBaseModel(models.Model):
Expand Down Expand Up @@ -209,6 +210,16 @@ def default(cls):
return cls.GOAL


class SubmitStatus(models.IntegerChoices):
DRAFT = 0, _("درفت")
INITIAL_SUBMIT = 1, _("ثبت اولیه")
FINAL_SUBMIT = 2, _("ثبت نهایی")

@classmethod
def default(cls):
return cls.DRAFT


class Note(MerlinBaseModel):
owner = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="نویسنده")
title = models.CharField(max_length=512, verbose_name="عنوان")
Expand All @@ -233,6 +244,11 @@ class Note(MerlinBaseModel):
linked_notes = models.ManyToManyField(
"Note", related_name="connected_notes", blank=True, verbose_name="پیوندها"
)
submit_status = models.IntegerField(
choices=SubmitStatus.choices,
default=SubmitStatus.default(),
verbose_name="وضعیت",
)

class Meta:
verbose_name = "یادداشت"
Expand Down Expand Up @@ -277,6 +293,11 @@ class Summary(MerlinBaseModel):
committee_date = models.DateField(
blank=True, null=True, verbose_name="تاریخ برگزاری جلسه‌ی کمیته"
)
submit_status = models.IntegerField(
choices=SubmitStatus.choices,
default=SubmitStatus.default(),
verbose_name="وضعیت",
)

class Meta:
verbose_name = "جمع‌بندی"
Expand Down
6 changes: 6 additions & 0 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class NoteSerializer(serializers.ModelSerializer):
)
read_status = serializers.SerializerMethodField()
access_level = serializers.SerializerMethodField()
submit_status_name = serializers.CharField(source='get_submit_status_display')

class Meta:
model = Note
Expand All @@ -104,6 +105,8 @@ class Meta:
"linked_notes",
"read_status",
"access_level",
"submit_status",
"submit_status_name",
)
read_only_fields = [
"uuid",
Expand Down Expand Up @@ -168,6 +171,7 @@ def create(self, validated_data):

class SummarySerializer(serializers.ModelSerializer):
note = serializers.SlugRelatedField(read_only=True, slug_field="uuid")
submit_status_name = serializers.CharField(source='get_submit_status_display')

class Meta:
model = Summary
Expand All @@ -180,6 +184,8 @@ class Meta:
"bonus",
"salary_change",
"committee_date",
"submit_status",
"submit_status_name",
)
read_only_fields = ["uuid"]

Expand Down

0 comments on commit 744011f

Please sign in to comment.