diff --git a/bfportal/core/templates/core/experience_page.html b/bfportal/core/templates/core/experience_page.html index 931023d..fddff34 100644 --- a/bfportal/core/templates/core/experience_page.html +++ b/bfportal/core/templates/core/experience_page.html @@ -11,6 +11,7 @@ + {% if debug %}{% static "images/placeholder.png" %}{% else %}{% if page.cover_img_url %}{{ page.cover_img_url }}{% else %}{% static "images/placeholder.png" %}{% endif %}{% endif %}' alt="{{ page.slug }}" onerror='if(this.src !== "{% static "images/placeholder.png" %}") this.src="{% static "images/placeholder.png" %}";' @@ -27,6 +28,7 @@ width="32" height="32" src=" + {% if page|is_liked_by_user:request %}{% static 'svgs/card/heart_liked.svg' %}{% else %}{% static 'svgs/card/heart_not_liked.svg' %}{% endif %}" alt="" /> @@ -39,47 +41,75 @@
Report
+ + + {% if page.owner == request.user %} +Change State
+ {% if page.bugged_report.all|length %} + {{ page.bugged_report.all|length }} + {% endif %} + {% if page.broken_report.all|length %} + {{ page.broken_report.all|length }} + {% endif %} + + {% else %} + Report + {% endif %} + +{{ page.bugged_report.all|length }}
+ {% endif %} + + + Experience Not Available + {% if page.owner == request.user %} +{{ page.broken_report.all|length }}
+ {% endif %} + + {% if page.owner != request.user %} + XP Farm + {% endif %} + + {% endwith %} +@@ -37,8 +39,7 @@
Editable - +
{% endif %} {% endif %} diff --git a/bfportal/core/views.py b/bfportal/core/views.py index dfff5c7..5cfa650 100644 --- a/bfportal/core/views.py +++ b/bfportal/core/views.py @@ -35,6 +35,7 @@ class ReportTypes(enum.Enum, metaclass=EnumMeta): BUGGED = 0 BROKEN = 1 XP_FARM = 2 + OK = 4 def send_approve_request( @@ -337,15 +338,44 @@ def report_experience(request: HttpRequest, report_type: int): except ExperiencePage.DoesNotExist: logger.debug(f"Wrong page id {page_id}") return HttpResponse(status=400) + save_page = True + response_text = "Reported Successfully" match report_type: + case ReportTypes.OK: + if exp_page.owner == request.user: + exp_page.bugged = False + exp_page.broken = False + exp_page.save_revision( + user=request.user, + submitted_for_moderation=True, + changed=True, + ) + return HttpResponse("Awaiting approval", status=200) + else: + return HttpResponse( + "Nice try... reported :)", status=404 + ) + case ReportTypes.BUGGED: - exp_page.bugged_report.add(request.user) + if exp_page.owner == request.user: + exp_page.bugged = True + response_text = "State Change Successful" + else: + exp_page.bugged_report.add(request.user) + case ReportTypes.BROKEN: - exp_page.broken_report.add(request.user) + if exp_page.owner == request.user: + exp_page.broken = True + response_text = "State Change Successful" + else: + exp_page.broken_report.add(request.user) + case ReportTypes.XP_FARM: exp_page.xp_farm_report.add(request.user) - exp_page.save() - return HttpResponse(status=200) + + if save_page: + exp_page.save() + return HttpResponse(response_text, status=200) else: logger.debug(f"Wrong page id {page_id}") return HttpResponse(status=400)