Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/HomeRateDev/HomeRate
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeshanA committed Jun 18, 2018
2 parents fcb64f4 + aed3291 commit c8593fa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
21 changes: 21 additions & 0 deletions homerate/reviews/templates/reviews/suspicious_report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends "homepage/base.html" %}

{% block title %}
Activation Successful
{% endblock %}

{% block content %}
<div class="container">
<p class="message">Your review has been flagged for suspicious images and will be reviewed before submission.</p>
<p>You will be redirected in <span id="counter">10</span> seconds.</p>
<script>
setInterval(function() {
var div = document.querySelector("#counter");
var count = div.textContent * 1 - 1;
div.textContent = count;
if (count <= 0) {
window.location.replace("{% url 'house' id=id %}");
}
}, 1000);
</script>
{% endblock %}
15 changes: 14 additions & 1 deletion homerate/reviews/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,20 +150,33 @@ def new_report(request, id):
report.save()
house_details_form.save()

# By default profiles don't need review
needs_review = False

for img in image_formset:
try:
# Save the reviews to the database
photo = ReviewImage(house_report=report, image=img.cleaned_data['image'])
photo.save()

# If the image is adult content then delete the file and remove the database entry
# If the image is adult content then delete the file, remove the database entry
if is_adult_content(photo.image.url):
# Delete the image from the database
ReviewImage.objects.get(pk=photo.pk).delete()

# Flag for review and nake the report no longer visible
needs_review = True
report.visible = False
report.save(update_fields=["visible"])

except Exception as e:
# Users may not insert photos in order. Try remaining photos.
continue

# If needs a manual review then render a warning
if needs_review :
return render(request, 'reviews/suspicious_report.html', {'id': house.pk})

return redirect('house', id=house.id)
else:
print("Form Error")
Expand Down

0 comments on commit c8593fa

Please sign in to comment.