feat: add basic subscriptions
This commit is contained in:
parent
7c8dcaf171
commit
24b4b1fad0
@ -552,3 +552,9 @@ class BaseNotification(models.Model):
|
|||||||
|
|
||||||
class CommentNotification(BaseNotification):
|
class CommentNotification(BaseNotification):
|
||||||
comment = models.ForeignKey(Comment, on_delete=models.CASCADE, verbose_name=_('Antwort'))
|
comment = models.ForeignKey(Comment, on_delete=models.CASCADE, verbose_name=_('Antwort'))
|
||||||
|
|
||||||
|
|
||||||
|
class Subscriptions(models.Model):
|
||||||
|
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('Nutzer*in'))
|
||||||
|
adoption_notice = models.ForeignKey(AdoptionNotice, on_delete=models.CASCADE, verbose_name=_('AdoptionNotice'))
|
||||||
|
created_at = models.DateTimeField(auto_now_add=True)
|
@ -12,7 +12,7 @@ from notfellchen import settings
|
|||||||
|
|
||||||
from fellchensammlung import logger
|
from fellchensammlung import logger
|
||||||
from .models import AdoptionNotice, Text, Animal, Rule, Image, Report, ModerationAction, \
|
from .models import AdoptionNotice, Text, Animal, Rule, Image, Report, ModerationAction, \
|
||||||
User, Location, AdoptionNoticeStatus
|
User, Location, AdoptionNoticeStatus, Subscriptions
|
||||||
from .forms import AdoptionNoticeForm, AdoptionNoticeFormWithDateWidget, ImageForm, ReportAdoptionNoticeForm, \
|
from .forms import AdoptionNoticeForm, AdoptionNoticeFormWithDateWidget, ImageForm, ReportAdoptionNoticeForm, \
|
||||||
CommentForm, ReportCommentForm, AnimalForm, \
|
CommentForm, ReportCommentForm, AnimalForm, \
|
||||||
AdoptionNoticeSearchForm, AnimalFormWithDateWidget
|
AdoptionNoticeSearchForm, AnimalFormWithDateWidget
|
||||||
@ -61,6 +61,10 @@ def adoption_notice_detail(request, adoption_notice_id):
|
|||||||
comment_instance.adoption_notice_id = adoption_notice_id
|
comment_instance.adoption_notice_id = adoption_notice_id
|
||||||
comment_instance.user = request.user.member
|
comment_instance.user = request.user.member
|
||||||
comment_instance.save()
|
comment_instance.save()
|
||||||
|
|
||||||
|
# Auto-subscribe user to adoption notice
|
||||||
|
subscription = Subscriptions(adoption_notice=adoption_notice, user=request.user)
|
||||||
|
subscription.save()
|
||||||
else:
|
else:
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user