Commit 86e8aa18 authored by Benoit Alessandroni's avatar Benoit Alessandroni

Adding proper notifications to go back into the validation loop

parent d3e54660
......@@ -221,6 +221,28 @@ def create_review(sender, instance, created, **kwargs):
reviewInstance = Review.objects.create(resource=instance, status="pending")
instance.review = reviewInstance
instance.save()
if not created:
#TODO: If we are updating a resource which requires improvement,
#we can send a notification to the current reviewer for further review
#and switch the review to pending
if instance.review.status == 'to_improve':
review = instance.review
review.status='pending'
review.save()
message = loader.render_to_string(
'reviewer_modification_notification.txt',
{
'review': review,
'resource': instance
}
)
send_mail(
'The resource you reviewed has been modified',
message,
review.reviewer.email,
[review.reviewer.email]
)
@receiver(post_save, sender=Review)
def update_review(sender, instance, created, **kwargs):
......@@ -234,7 +256,7 @@ def update_review(sender, instance, created, **kwargs):
message = loader.render_to_string(
'resource_validation_notification.txt',
{
'review': instance,
'review': instance,
'resource': resource
}
)
......@@ -242,22 +264,23 @@ def update_review(sender, instance, created, **kwargs):
message = loader.render_to_string(
'resource_improvement_notification.txt',
{
'review': instance,
'review': instance,
'resource': resource
}
)
else:
elif instance.status == 'inappropriate':
message = loader.render_to_string(
'resource_refusal_notification.txt',
{
'review': instance,
'review': instance,
'resource': resource
}
)
send_mail(
'The resource you submitted have been reviewed',
message,
resource.submitter.email,
[resource.submitter.email]
)
\ No newline at end of file
if instance.status != 'pending':
send_mail(
'The resource you submitted has been reviewed',
message,
resource.submitter.email,
[resource.submitter.email]
)
\ No newline at end of file
......@@ -10,6 +10,6 @@ URI: {{resource.uri}}
Improvement proposal detail: {{review.comment}}
Have a nice day,
Connect to the Knowledge Base now to edit this resource.
The Knowledge Base Team.
\ No newline at end of file
Hello {{review.reviewer.name|safe}}
{{resource.submitter.name|safe}} implemented the improvement you suggested on the following resource.
Title: {{resource.name}}
Description: {{resource.description}}
URI: {{resource.uri}}
Improvement proposal detail: {{review.comment}}
Connect now to validate it.
The Knowledge Base Team.
\ No newline at end of file
......@@ -7,4 +7,4 @@ class PendingResourcesViewSet(LDPViewSet):
def get_queryset(self, *args, **kwargs):
return super().get_queryset(*args, **kwargs)\
.filter(review__status='pending', language__in=self.request.user.mentor_profile.languages.all(), fields__in=self.request.user.mentor_profile.fields.all())\
.exclude(submitter=self.request.user)
\ No newline at end of file
.exclude(submitter__username=self.request.user.username)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment