Fix OTP/SMS, ledger accounting, order tracking, and add reviews app
- Add MessageTemplate.runtime_field_labels so mobile's per-field execution-time labels are actually persisted (were silently dropped) - Fix AdvanceOrderStageView reading the wrong extra-input key, and be honest about SMS send failures instead of always claiming success - Add admin gift-gem SMS notification via Kavenegar - Post real double-entry Transactions for plain (non-invoice) ledger entries so trial balance, the معین screen, and CSV/XLSX exports actually include everyday income/expense entries; backfill existing historical entries via data migration - Rewrite CSV ledger export to produce an actual دفتر معین structure (per-account running balance) instead of a flat row dump - Add invoice percent/promotional discounts, tax presets, ledger discount-percent handling, product SKU/category/expiry fields, and manual ledger-book archiving (replacing auto-archive on new book) - Add reviews app (models, API, admin) for the comments/reviews feature - Update tests for the above; fix two stale assertions left over from earlier work in this branch (معین sheet name, book auto-close)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
# «نظرات» — یک دیوارِ بازخوردِ ساده، عمداً بدونِ گفتوگو: هر کاربر فقط یک
|
||||
# نظر دارد (نوشتنِ دوباره همان نظر را جایگزین میکند، نه یک ردیفِ تازه)،
|
||||
# نظرات فقط لایک میخورند (نه ریپلای)، و فقط بعد از تاییدِ ادمین در فهرستِ
|
||||
# عمومی دیده میشوند — نوشتن/ویرایشِ دوباره وضعیتِ تایید را برمیگرداند به
|
||||
# «در انتظار» تا کسی نتواند یک نظرِ تاییدشده را بیبازبینی به چیزِ دیگری
|
||||
# تغییر بدهد.
|
||||
|
||||
|
||||
class Review(models.Model):
|
||||
user = models.OneToOneField(
|
||||
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="review"
|
||||
)
|
||||
body = models.TextField(max_length=1000, verbose_name=_("متن نظر"))
|
||||
is_approved = models.BooleanField(default=False, verbose_name=_("تاییدشده"))
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("نظر")
|
||||
verbose_name_plural = _("نظرات")
|
||||
ordering = ["-created_at"]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.user.phone} — {self.body[:30]}"
|
||||
|
||||
@property
|
||||
def like_count(self) -> int:
|
||||
return self.likes.count()
|
||||
|
||||
|
||||
class ReviewLike(models.Model):
|
||||
review = models.ForeignKey(Review, on_delete=models.CASCADE, related_name="likes")
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="review_likes"
|
||||
)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("لایک نظر")
|
||||
verbose_name_plural = _("لایکهای نظر")
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["review", "user"], name="unique_review_like")
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.user.phone} ← {self.review_id}"
|
||||
Reference in New Issue
Block a user