From 2ff3efaadff0c9813e189fd2c9d54093835ac735 Mon Sep 17 00:00:00 2001 From: Bishal <69814108+CodeWithBishal@users.noreply.github.com> Date: Wed, 6 Mar 2024 23:26:14 +0530 Subject: [PATCH 01/14] issue 1627 - 1 ## Title and Open Graph Tags Meta tags are now dynamically updating moved issue.html to REMOVE folder signifying it can be removed and no longer required likewise issue2.html can be moved after issue3.html is ready --- blt/urls.py | 6 +- contributors.json | 43 +- website/{templates => REMOVE}/issue.html | 0 website/templates/base.html | 13 +- website/templates/issue3.html | 564 +++++++++++++++++++++++ website/views.py | 235 +++++++--- 6 files changed, 767 insertions(+), 94 deletions(-) rename website/{templates => REMOVE}/issue.html (100%) create mode 100644 website/templates/issue3.html diff --git a/blt/urls.py b/blt/urls.py index e6031f38d..40623d619 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -53,8 +53,9 @@ InboundParseWebhookView, InviteCreate, IssueCreate, - IssueView, + # IssueView, IssueView2, + IssueView3, JoinCompany, ListHunts, OngoingHunts, @@ -301,8 +302,9 @@ ), # delete_comment path("issue2/comment/delete/", website.views.delete_comment, name="delete_comment"), - re_path(r"^issue/(?P\w+)/$", IssueView.as_view(), name="issue_view"), + # P.S.(can be removed): re_path(r"^issue/(?P\w+)/$", IssueView.as_view(), name="issue_view"), re_path(r"^issue2/(?P\w+)/$", IssueView2.as_view(), name="issue_view2"), + re_path(r"^issue3/(?P\w+)/$", IssueView3.as_view(), name="issue_view3"), re_path(r"^follow/(?P[^/]+)/", website.views.follow_user, name="follow_user"), re_path(r"^all_activity/$", AllIssuesView.as_view(), name="all_activity"), re_path(r"^label_activity/$", SpecificIssuesView.as_view(), name="all_activitys"), diff --git a/contributors.json b/contributors.json index 3b74e5e3e..e1fcdfa87 100644 --- a/contributors.json +++ b/contributors.json @@ -54,6 +54,19 @@ }, { "id":5, + "img":"https://avatars.githubusercontent.com/u/69814108?v=4", + "name":"Bishal Das", + "repository":"BLT Core", + "short_description":"Full Stack Developer", + "long_description":"", + "location":"Indore, India", + "twitter":"", + "linkedin":"https://www.linkedin.com/in/bishal-das-bd/", + "website":"https://github.com/CodeWithBishal/", + "bch_addr":"" + }, + { + "id":6, "img":"https://avatars.githubusercontent.com/u/47253186?v=4", "name":"Pulkit Agrawal", "repository":"BLT Core", @@ -66,7 +79,7 @@ "bch_addr":"" }, { - "id":6, + "id":7, "img":"https://avatars.githubusercontent.com/u/65587505?v=4", "name":"Amrit Prakash", "repository":"BLT Flutter", @@ -79,7 +92,7 @@ "bch_addr":"" }, { - "id":7, + "id":8, "img":"https://avatars.githubusercontent.com/u/16963976?v=4", "name":"Mohit Anand", "repository":"", @@ -92,7 +105,7 @@ "bch_addr":"" }, { - "id":8, + "id":9, "img":"https://avatars.githubusercontent.com/u/11073943?v=4", "name":"Sourav Badami", "repository":"", @@ -105,7 +118,7 @@ "bch_addr":"" }, { - "id":9, + "id":10, "img":"https://avatars.githubusercontent.com/u/22706287?v=4", "name":"S Rahul Badami", "repository":"", @@ -118,7 +131,7 @@ "bch_addr":"" }, { - "id":10, + "id":11, "img":"https://avatars.githubusercontent.com/u/17125030?v=4", "name":"Siddharth Goyal", "repository":"", @@ -131,7 +144,7 @@ "bch_addr":"" }, { - "id":11, + "id":12, "img":"https://avatars.githubusercontent.com/u/20015262?v=4", "name":"Neethu Mariya Joy", "repository":"", @@ -144,7 +157,7 @@ "bch_addr":"" }, { - "id":12, + "id":13, "img":"https://avatars.githubusercontent.com/u/128622481?v=4", "name":"DonnieBLT", "repository":"", @@ -157,7 +170,7 @@ "bch_addr":"" }, { - "id":13, + "id":14, "img":"https://avatars.githubusercontent.com/u/44541855?v=4", "name":"Ankit Choudhary", "repository":"", @@ -170,7 +183,7 @@ "bch_addr":"" }, { - "id":14, + "id":15, "img":"https://avatars.githubusercontent.com/u/103092293?v=4", "name":"Cody Ross", "repository":"", @@ -183,7 +196,7 @@ "bch_addr":"" }, { - "id":15, + "id":16, "img":"https://avatars.githubusercontent.com/u/53966291?v=4", "name":"Mrigank Anand", "repository":"", @@ -196,7 +209,7 @@ "bch_addr":"" }, { - "id":16, + "id":17, "img":"https://avatars.githubusercontent.com/u/55937724?v=4", "name":"Sparsh Agrawal", "repository":"", @@ -209,7 +222,7 @@ "bch_addr":"" }, { - "id":17, + "id":18, "img":"https://avatars.githubusercontent.com/u/99071926?v=4", "name":"Kej-r03", "repository":"", @@ -222,7 +235,7 @@ "bch_addr":"" }, { - "id":18, + "id":19, "img":"https://avatars.githubusercontent.com/u/81790585?v=4", "name":"Bhawna", "repository":"", @@ -235,7 +248,7 @@ "bch_addr":"" }, { - "id":19, + "id":20, "img":"https://avatars.githubusercontent.com/u/17159160?v=4", "name":"Rohit Lodha", "repository":"", @@ -248,7 +261,7 @@ "bch_addr":"" }, { - "id":20, + "id":21, "img":"https://avatars.githubusercontent.com/u/89926834?v=4", "name":"Manish Bisht", "repository":"", diff --git a/website/templates/issue.html b/website/REMOVE/issue.html similarity index 100% rename from website/templates/issue.html rename to website/REMOVE/issue.html diff --git a/website/templates/base.html b/website/templates/base.html index 6212ea0c3..630c43ac0 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -8,14 +8,15 @@ + + + + {% block metaTags %} {% block title %} {% env 'PROJECT_NAME' %} {% endblock title %} - - - + {% endblock metaTags %} + + @@ -84,7 +89,7 @@ {% comment %} navigation {% endcomment %} {% include "includes/header.html" %} {% comment %} navigation {% endcomment %} -
+
{% block content %} {% endblock content %}
diff --git a/website/templates/issue3.html b/website/templates/issue3.html new file mode 100644 index 000000000..85e767041 --- /dev/null +++ b/website/templates/issue3.html @@ -0,0 +1,564 @@ +{% extends "base.html" %} +{% load custom_tags %} +{% block metaTags %} + + {% block title %} BLT Issue - {{ object.description }} {% endblock title %} + + +{% if object.user.username %} + + +{% else %} + + +{% endif %} + +{% for screenshot in screenshots %} + +{% endfor %} + + + +{% comment %} TODO: change to update {% endcomment %} + + + + + + + +{% endblock metaTags %} +{% load static %} +{% load gravatar %} +{% load custom_tags %} +{% block head %} + +{% endblock head %} +{% block content %} +{% include "includes/sidenav.html" %} +
+ + Lorem ipsum dolor sit amet consectetur adipisicing elit. Suscipit inventore provident dolorum et, in dolorem maxime explicabo praesentium doloribus officiis laboriosam iusto laudantium! Ad architecto dolor cumque perferendis quidem libero doloremque nam quo, molestias repellat, nobis vitae porro veritatis non voluptatibus. Eaque beatae cumque illo quo nulla quisquam, recusandae earum distinctio voluptatibus delectus facilis quae reiciendis mollitia nobis, dolor itaque unde explicabo natus? Itaque doloribus nihil ducimus praesentium repellendus quis quasi cupiditate dicta inventore assumenda optio eveniet numquam labore odio provident blanditiis maiores veritatis, placeat explicabo reprehenderit facere aspernatur distinctio vero. Quae a corporis expedita quis provident iure ut asperiores. +
+ {% comment %}
+
+
+
+
+

+ Published on + {{ object.created }} +

+

+ Reported on + {{ object.url }} +

+

+ {{ object.description }} +

+ +
+
+
+
+
+
+
+ {% if object.user.username %} + {% if object.user.userprofile.user_avatar %} + User Profile Logo + {% else %} + User Profile Logo + {% endif %} + {% else %} + User Profile Logo + {% endif %} +
+
+ {% if object.user.username %} + + Reported By + {{ object.user.username }} + + {% else %} + + Reported By + Anonymous + + {% endif %} +

+ Report viewed by {{ object.views }} users +

+
+
+
+ {% include "includes/_likes2.html" %} + {% include "includes/_dislike2.html" %} + {% include "includes/_flags2.html" %} + {% include "includes/_bookmark2.html" %} + + + Share + +
+
+

Screenshots (5)

+
+ {% if object.screenshot %} + + Image thumbnail + + {% else %} + {% for screenshot in screenshots %} + + Screenshot + + {% endfor %} + {% endif %} +
+ +
+
+
+
+
+
+
+

Bug Type:

+ {{ object.get_label_display }} +
+
+

Status:

+
+ {% if request.user == object.user or request.is_staff or request.is_superuser %} + + Click + to + {% if object.status == "open" %} + Close + {% else %} + Open + {% endif %} + + {% endif %} + {{ object.status }} +
+
+
+

Reported On:

+ {{ object.created }} +
+
+

Submitted:

+ {% if object.hunt is None %} + Independently + {% else %} + {{ object.hunt.name }} + {% endif %} +
+ {% if request.user.is_superuser or request.user == object.user %} +
+

Report Anonymously:

+ {% if object.user %} +
+ {% csrf_token %} + + + +
+ {% endif %} +
+ +
+

Delete Issue:

+ + + +
+ +
+

Edit Issue:

+ Yes +
+ {% endif %} +
+
+
+
+
+
+ {% if browser_family %} + {% with "img/browser-logos/"|add:browser_family|add:"/"|add:browser_family|add:"_64x64.png"|lower as image_static %} + Browser Image + {% endwith %} + {% endif %} +
+
+

+ Browser Version: {{ browser_version }} +

+

+ Operating System: {{ os_family }} +

+

+ OS Version: + {% if os_version %} + {{ os_version }} + {% else %} + Unknown + {% endif %} + +

+
+
+
+
+
+
+ Domain Logo +
+
+ Reported on {{ object.domain.name }} +

+ Total {{ issue_count }} bugs reported +

+
+
+
+ +
+
+
+
+
+ {% if object.user.username %} + {% if object.user.userprofile.user_avatar %} + User Profile Logo + {% else %} + User Profile Logo + {% endif %} + {% else %} + User Profile Logo + {% endif %} +
+
+ {% if object.user.username %} + Reported By {{ object.user.username }} + {% else %} + Reported By Anonymous + {% endif %} +

+ Total points {{ users_score }} +

+
+
+
+ +
+
+
+
+ {% include "comments2.html" %} +
+
+
+ {% endcomment %} + + + + +{% endblock content %} \ No newline at end of file diff --git a/website/views.py b/website/views.py index cc98e5c4d..7e587fc86 100644 --- a/website/views.py +++ b/website/views.py @@ -1894,79 +1894,79 @@ def get_success_url(self): return "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HH7MNY6KJGZFW" -class IssueView(DetailView): - model = Issue - slug_field = "id" - template_name = "issue.html" - - def get(self, request, *args, **kwargs): - ipdetails = IP() - try: - id = int(self.kwargs["slug"]) - except ValueError: - return HttpResponseNotFound("Invalid ID: ID must be an integer") - - self.object = get_object_or_404(Issue, id=self.kwargs["slug"]) - ipdetails.user = self.request.user - ipdetails.address = get_client_ip(request) - ipdetails.issuenumber = self.object.id - try: - if self.request.user.is_authenticated: - try: - objectget = IP.objects.get(user=self.request.user, issuenumber=self.object.id) - self.object.save() - except: - ipdetails.save() - self.object.views = (self.object.views or 0) + 1 - self.object.save() - else: - try: - objectget = IP.objects.get( - address=get_client_ip(request), issuenumber=self.object.id - ) - self.object.save() - except Exception as e: - print(e) - messages.error(self.request, "That issue was not found 2." + str(e)) - ipdetails.save() - self.object.views = (self.object.views or 0) + 1 - self.object.save() - except Exception as e: - print(e) - messages.error(self.request, "That issue was not found 1." + str(e)) - return redirect("/") - return super(IssueView, self).get(request, *args, **kwargs) - - def get_context_data(self, **kwargs): - context = super(IssueView, self).get_context_data(**kwargs) - if self.object.user_agent: - user_agent = parse(self.object.user_agent) - context["browser_family"] = user_agent.browser.family - context["browser_version"] = user_agent.browser.version_string - context["os_family"] = user_agent.os.family - context["os_version"] = user_agent.os.version_string - context["users_score"] = list( - Points.objects.filter(user=self.object.user) - .aggregate(total_score=Sum("score")) - .values() - )[0] - - if self.request.user.is_authenticated: - context["wallet"] = Wallet.objects.get(user=self.request.user) - context["issue_count"] = Issue.objects.filter(url__contains=self.object.domain_name).count() - context["all_comment"] = self.object.comments.all - context["all_users"] = User.objects.all() - context["likes"] = UserProfile.objects.filter(issue_upvoted=self.object).count() - context["likers"] = UserProfile.objects.filter(issue_upvoted=self.object) - context["dislikes"] = UserProfile.objects.filter(issue_downvoted=self.object).count() - context["dislikers"] = UserProfile.objects.filter(issue_downvoted=self.object) - - context["flags"] = UserProfile.objects.filter(issue_flaged=self.object).count() - context["flagers"] = UserProfile.objects.filter(issue_flaged=self.object) - - context["screenshots"] = IssueScreenshot.objects.filter(issue=self.object).all() - - return context +# class IssueView(DetailView): +# model = Issue +# slug_field = "id" +# template_name = "issue.html" + +# def get(self, request, *args, **kwargs): +# ipdetails = IP() +# try: +# id = int(self.kwargs["slug"]) +# except ValueError: +# return HttpResponseNotFound("Invalid ID: ID must be an integer") + +# self.object = get_object_or_404(Issue, id=self.kwargs["slug"]) +# ipdetails.user = self.request.user +# ipdetails.address = get_client_ip(request) +# ipdetails.issuenumber = self.object.id +# try: +# if self.request.user.is_authenticated: +# try: +# objectget = IP.objects.get(user=self.request.user, issuenumber=self.object.id) +# self.object.save() +# except: +# ipdetails.save() +# self.object.views = (self.object.views or 0) + 1 +# self.object.save() +# else: +# try: +# objectget = IP.objects.get( +# address=get_client_ip(request), issuenumber=self.object.id +# ) +# self.object.save() +# except Exception as e: +# print(e) +# messages.error(self.request, "That issue was not found 2." + str(e)) +# ipdetails.save() +# self.object.views = (self.object.views or 0) + 1 +# self.object.save() +# except Exception as e: +# print(e) +# messages.error(self.request, "That issue was not found 1." + str(e)) +# return redirect("/") +# return super(IssueView, self).get(request, *args, **kwargs) + +# def get_context_data(self, **kwargs): +# context = super(IssueView, self).get_context_data(**kwargs) +# if self.object.user_agent: +# user_agent = parse(self.object.user_agent) +# context["browser_family"] = user_agent.browser.family +# context["browser_version"] = user_agent.browser.version_string +# context["os_family"] = user_agent.os.family +# context["os_version"] = user_agent.os.version_string +# context["users_score"] = list( +# Points.objects.filter(user=self.object.user) +# .aggregate(total_score=Sum("score")) +# .values() +# )[0] + +# if self.request.user.is_authenticated: +# context["wallet"] = Wallet.objects.get(user=self.request.user) +# context["issue_count"] = Issue.objects.filter(url__contains=self.object.domain_name).count() +# context["all_comment"] = self.object.comments.all +# context["all_users"] = User.objects.all() +# context["likes"] = UserProfile.objects.filter(issue_upvoted=self.object).count() +# context["likers"] = UserProfile.objects.filter(issue_upvoted=self.object) +# context["dislikes"] = UserProfile.objects.filter(issue_downvoted=self.object).count() +# context["dislikers"] = UserProfile.objects.filter(issue_downvoted=self.object) + +# context["flags"] = UserProfile.objects.filter(issue_flaged=self.object).count() +# context["flagers"] = UserProfile.objects.filter(issue_flaged=self.object) + +# context["screenshots"] = IssueScreenshot.objects.filter(issue=self.object).all() + +# return context @login_required(login_url="/accounts/login") @@ -3791,6 +3791,95 @@ def get_context_data(self, **kwargs): return context +class IssueView3(DetailView): + model = Issue + slug_field = "id" + template_name = "issue3.html" + + def get(self, request, *args, **kwargs): + ipdetails = IP() + try: + id = int(self.kwargs["slug"]) + except ValueError: + return HttpResponseNotFound("Invalid ID: ID must be an integer") + + self.object = get_object_or_404(Issue, id=self.kwargs["slug"]) + ipdetails.user = self.request.user + ipdetails.address = get_client_ip(request) + ipdetails.issuenumber = self.object.id + try: + if self.request.user.is_authenticated: + try: + objectget = IP.objects.get(user=self.request.user, issuenumber=self.object.id) + self.object.save() + except: + ipdetails.save() + self.object.views = (self.object.views or 0) + 1 + self.object.save() + else: + try: + objectget = IP.objects.get( + address=get_client_ip(request), issuenumber=self.object.id + ) + self.object.save() + except: + ipdetails.save() + self.object.views = (self.object.views or 0) + 1 + self.object.save() + except Exception as e: + print(e) + # TODO: this is only an error for ipv6 currently and doesn't require us to redirect the user - we'll sort this out later + # messages.error(self.request, "That issue was not found."+str(e)) + # return redirect("/") + return super(IssueView3, self).get(request, *args, **kwargs) + + def get_context_data(self, **kwargs): + context = super(IssueView3, self).get_context_data(**kwargs) + if self.object.user_agent: + user_agent = parse(self.object.user_agent) + context["browser_family"] = user_agent.browser.family + context["browser_version"] = user_agent.browser.version_string + context["os_family"] = user_agent.os.family + context["os_version"] = user_agent.os.version_string + context["users_score"] = list( + Points.objects.filter(user=self.object.user) + .aggregate(total_score=Sum("score")) + .values() + )[0] + + if self.request.user.is_authenticated: + context["wallet"] = Wallet.objects.get(user=self.request.user) + context["issue_count"] = Issue.objects.filter(url__contains=self.object.domain_name).count() + context["all_comment"] = self.object.comments.all().order_by("-created_date") + context["all_users"] = User.objects.all() + context["likes"] = UserProfile.objects.filter(issue_upvoted=self.object).count() + context["likers"] = UserProfile.objects.filter(issue_upvoted=self.object) + context["flags"] = UserProfile.objects.filter(issue_flaged=self.object).count() + context["flagers"] = UserProfile.objects.filter(issue_flaged=self.object) + context["more_issues"] = ( + Issue.objects.filter(user=self.object.user) + .exclude(id=self.object.id) + .values("id", "description", "markdown_description", "screenshots__image") + .order_by("views")[:4] + ) + context["subscribed_to_domain"] = False + + if isinstance(self.request.user, User): + context["subscribed_to_domain"] = self.object.domain.user_subscribed_domains.filter( + pk=self.request.user.userprofile.id + ).exists() + + if isinstance(self.request.user, User): + context["bookmarked"] = self.request.user.userprofile.issue_saved.filter( + pk=self.object.id + ).exists() + + context["screenshots"] = IssueScreenshot.objects.filter(issue=self.object).all() + + return context + + + @receiver(user_signed_up) def handle_user_signup(request, user, **kwargs): From fbc5e6291455a0414f2b5cc404d8f6106f82418e Mon Sep 17 00:00:00 2001 From: Bishal <69814108+CodeWithBishal@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:01:31 +0530 Subject: [PATCH 02/14] Update urls.py --- blt/urls.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blt/urls.py b/blt/urls.py index 40623d619..48df79729 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -31,7 +31,7 @@ UserIssueViewSet, UserProfileViewSet, ) -from website.views import ( +from website.views import ( # IssueView, AllIssuesView, CompanySettings, ContributorStatsView, @@ -53,7 +53,6 @@ InboundParseWebhookView, InviteCreate, IssueCreate, - # IssueView, IssueView2, IssueView3, JoinCompany, From c9219f50c3672171dff8c428db0bff07e1f1d0f5 Mon Sep 17 00:00:00 2001 From: Bishal <69814108+CodeWithBishal@users.noreply.github.com> Date: Wed, 6 Mar 2024 23:26:14 +0530 Subject: [PATCH 03/14] issue 1627 - 1 ## Title and Open Graph Tags Meta tags are now dynamically updating moved issue.html to REMOVE folder signifying it can be removed and no longer required likewise issue2.html can be moved after issue3.html is ready --- blt/urls.py | 6 +- contributors.json | 43 +- website/{templates => REMOVE}/issue.html | 0 website/templates/base.html | 13 +- website/templates/issue3.html | 564 +++++++++++++++++++++++ website/views.py | 235 +++++++--- 6 files changed, 767 insertions(+), 94 deletions(-) rename website/{templates => REMOVE}/issue.html (100%) create mode 100644 website/templates/issue3.html diff --git a/blt/urls.py b/blt/urls.py index e6031f38d..40623d619 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -53,8 +53,9 @@ InboundParseWebhookView, InviteCreate, IssueCreate, - IssueView, + # IssueView, IssueView2, + IssueView3, JoinCompany, ListHunts, OngoingHunts, @@ -301,8 +302,9 @@ ), # delete_comment path("issue2/comment/delete/", website.views.delete_comment, name="delete_comment"), - re_path(r"^issue/(?P\w+)/$", IssueView.as_view(), name="issue_view"), + # P.S.(can be removed): re_path(r"^issue/(?P\w+)/$", IssueView.as_view(), name="issue_view"), re_path(r"^issue2/(?P\w+)/$", IssueView2.as_view(), name="issue_view2"), + re_path(r"^issue3/(?P\w+)/$", IssueView3.as_view(), name="issue_view3"), re_path(r"^follow/(?P[^/]+)/", website.views.follow_user, name="follow_user"), re_path(r"^all_activity/$", AllIssuesView.as_view(), name="all_activity"), re_path(r"^label_activity/$", SpecificIssuesView.as_view(), name="all_activitys"), diff --git a/contributors.json b/contributors.json index 3b74e5e3e..e1fcdfa87 100644 --- a/contributors.json +++ b/contributors.json @@ -54,6 +54,19 @@ }, { "id":5, + "img":"https://avatars.githubusercontent.com/u/69814108?v=4", + "name":"Bishal Das", + "repository":"BLT Core", + "short_description":"Full Stack Developer", + "long_description":"", + "location":"Indore, India", + "twitter":"", + "linkedin":"https://www.linkedin.com/in/bishal-das-bd/", + "website":"https://github.com/CodeWithBishal/", + "bch_addr":"" + }, + { + "id":6, "img":"https://avatars.githubusercontent.com/u/47253186?v=4", "name":"Pulkit Agrawal", "repository":"BLT Core", @@ -66,7 +79,7 @@ "bch_addr":"" }, { - "id":6, + "id":7, "img":"https://avatars.githubusercontent.com/u/65587505?v=4", "name":"Amrit Prakash", "repository":"BLT Flutter", @@ -79,7 +92,7 @@ "bch_addr":"" }, { - "id":7, + "id":8, "img":"https://avatars.githubusercontent.com/u/16963976?v=4", "name":"Mohit Anand", "repository":"", @@ -92,7 +105,7 @@ "bch_addr":"" }, { - "id":8, + "id":9, "img":"https://avatars.githubusercontent.com/u/11073943?v=4", "name":"Sourav Badami", "repository":"", @@ -105,7 +118,7 @@ "bch_addr":"" }, { - "id":9, + "id":10, "img":"https://avatars.githubusercontent.com/u/22706287?v=4", "name":"S Rahul Badami", "repository":"", @@ -118,7 +131,7 @@ "bch_addr":"" }, { - "id":10, + "id":11, "img":"https://avatars.githubusercontent.com/u/17125030?v=4", "name":"Siddharth Goyal", "repository":"", @@ -131,7 +144,7 @@ "bch_addr":"" }, { - "id":11, + "id":12, "img":"https://avatars.githubusercontent.com/u/20015262?v=4", "name":"Neethu Mariya Joy", "repository":"", @@ -144,7 +157,7 @@ "bch_addr":"" }, { - "id":12, + "id":13, "img":"https://avatars.githubusercontent.com/u/128622481?v=4", "name":"DonnieBLT", "repository":"", @@ -157,7 +170,7 @@ "bch_addr":"" }, { - "id":13, + "id":14, "img":"https://avatars.githubusercontent.com/u/44541855?v=4", "name":"Ankit Choudhary", "repository":"", @@ -170,7 +183,7 @@ "bch_addr":"" }, { - "id":14, + "id":15, "img":"https://avatars.githubusercontent.com/u/103092293?v=4", "name":"Cody Ross", "repository":"", @@ -183,7 +196,7 @@ "bch_addr":"" }, { - "id":15, + "id":16, "img":"https://avatars.githubusercontent.com/u/53966291?v=4", "name":"Mrigank Anand", "repository":"", @@ -196,7 +209,7 @@ "bch_addr":"" }, { - "id":16, + "id":17, "img":"https://avatars.githubusercontent.com/u/55937724?v=4", "name":"Sparsh Agrawal", "repository":"", @@ -209,7 +222,7 @@ "bch_addr":"" }, { - "id":17, + "id":18, "img":"https://avatars.githubusercontent.com/u/99071926?v=4", "name":"Kej-r03", "repository":"", @@ -222,7 +235,7 @@ "bch_addr":"" }, { - "id":18, + "id":19, "img":"https://avatars.githubusercontent.com/u/81790585?v=4", "name":"Bhawna", "repository":"", @@ -235,7 +248,7 @@ "bch_addr":"" }, { - "id":19, + "id":20, "img":"https://avatars.githubusercontent.com/u/17159160?v=4", "name":"Rohit Lodha", "repository":"", @@ -248,7 +261,7 @@ "bch_addr":"" }, { - "id":20, + "id":21, "img":"https://avatars.githubusercontent.com/u/89926834?v=4", "name":"Manish Bisht", "repository":"", diff --git a/website/templates/issue.html b/website/REMOVE/issue.html similarity index 100% rename from website/templates/issue.html rename to website/REMOVE/issue.html diff --git a/website/templates/base.html b/website/templates/base.html index 6212ea0c3..630c43ac0 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -8,14 +8,15 @@ + + + + {% block metaTags %} {% block title %} {% env 'PROJECT_NAME' %} {% endblock title %} - - - + {% endblock metaTags %} + + @@ -84,7 +89,7 @@ {% comment %} navigation {% endcomment %} {% include "includes/header.html" %} {% comment %} navigation {% endcomment %} -
+
{% block content %} {% endblock content %}
diff --git a/website/templates/issue3.html b/website/templates/issue3.html new file mode 100644 index 000000000..85e767041 --- /dev/null +++ b/website/templates/issue3.html @@ -0,0 +1,564 @@ +{% extends "base.html" %} +{% load custom_tags %} +{% block metaTags %} + + {% block title %} BLT Issue - {{ object.description }} {% endblock title %} + + +{% if object.user.username %} + + +{% else %} + + +{% endif %} + +{% for screenshot in screenshots %} + +{% endfor %} + + + +{% comment %} TODO: change to update {% endcomment %} + + + + + + + +{% endblock metaTags %} +{% load static %} +{% load gravatar %} +{% load custom_tags %} +{% block head %} + +{% endblock head %} +{% block content %} +{% include "includes/sidenav.html" %} +
+ + Lorem ipsum dolor sit amet consectetur adipisicing elit. Suscipit inventore provident dolorum et, in dolorem maxime explicabo praesentium doloribus officiis laboriosam iusto laudantium! Ad architecto dolor cumque perferendis quidem libero doloremque nam quo, molestias repellat, nobis vitae porro veritatis non voluptatibus. Eaque beatae cumque illo quo nulla quisquam, recusandae earum distinctio voluptatibus delectus facilis quae reiciendis mollitia nobis, dolor itaque unde explicabo natus? Itaque doloribus nihil ducimus praesentium repellendus quis quasi cupiditate dicta inventore assumenda optio eveniet numquam labore odio provident blanditiis maiores veritatis, placeat explicabo reprehenderit facere aspernatur distinctio vero. Quae a corporis expedita quis provident iure ut asperiores. +
+ {% comment %}
+
+
+
+
+

+ Published on + {{ object.created }} +

+

+ Reported on + {{ object.url }} +

+

+ {{ object.description }} +

+ +
+
+
+
+
+
+
+ {% if object.user.username %} + {% if object.user.userprofile.user_avatar %} + User Profile Logo + {% else %} + User Profile Logo + {% endif %} + {% else %} + User Profile Logo + {% endif %} +
+
+ {% if object.user.username %} + + Reported By + {{ object.user.username }} + + {% else %} + + Reported By + Anonymous + + {% endif %} +

+ Report viewed by {{ object.views }} users +

+
+
+
+ {% include "includes/_likes2.html" %} + {% include "includes/_dislike2.html" %} + {% include "includes/_flags2.html" %} + {% include "includes/_bookmark2.html" %} + + + Share + +
+
+

Screenshots (5)

+
+ {% if object.screenshot %} + + Image thumbnail + + {% else %} + {% for screenshot in screenshots %} + + Screenshot + + {% endfor %} + {% endif %} +
+ +
+
+
+
+
+
+
+

Bug Type:

+ {{ object.get_label_display }} +
+
+

Status:

+
+ {% if request.user == object.user or request.is_staff or request.is_superuser %} + + Click + to + {% if object.status == "open" %} + Close + {% else %} + Open + {% endif %} + + {% endif %} + {{ object.status }} +
+
+
+

Reported On:

+ {{ object.created }} +
+
+

Submitted:

+ {% if object.hunt is None %} + Independently + {% else %} + {{ object.hunt.name }} + {% endif %} +
+ {% if request.user.is_superuser or request.user == object.user %} +
+

Report Anonymously:

+ {% if object.user %} +
+ {% csrf_token %} + + + +
+ {% endif %} +
+ +
+

Delete Issue:

+ + + +
+ +
+

Edit Issue:

+ Yes +
+ {% endif %} +
+
+
+
+
+
+ {% if browser_family %} + {% with "img/browser-logos/"|add:browser_family|add:"/"|add:browser_family|add:"_64x64.png"|lower as image_static %} + Browser Image + {% endwith %} + {% endif %} +
+
+

+ Browser Version: {{ browser_version }} +

+

+ Operating System: {{ os_family }} +

+

+ OS Version: + {% if os_version %} + {{ os_version }} + {% else %} + Unknown + {% endif %} + +

+
+
+
+
+
+
+ Domain Logo +
+
+ Reported on {{ object.domain.name }} +

+ Total {{ issue_count }} bugs reported +

+
+
+
+ +
+
+
+
+
+ {% if object.user.username %} + {% if object.user.userprofile.user_avatar %} + User Profile Logo + {% else %} + User Profile Logo + {% endif %} + {% else %} + User Profile Logo + {% endif %} +
+
+ {% if object.user.username %} + Reported By {{ object.user.username }} + {% else %} + Reported By Anonymous + {% endif %} +

+ Total points {{ users_score }} +

+
+
+
+ +
+
+
+
+ {% include "comments2.html" %} +
+
+
+ {% endcomment %} + + + + +{% endblock content %} \ No newline at end of file diff --git a/website/views.py b/website/views.py index cc98e5c4d..7e587fc86 100644 --- a/website/views.py +++ b/website/views.py @@ -1894,79 +1894,79 @@ def get_success_url(self): return "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HH7MNY6KJGZFW" -class IssueView(DetailView): - model = Issue - slug_field = "id" - template_name = "issue.html" - - def get(self, request, *args, **kwargs): - ipdetails = IP() - try: - id = int(self.kwargs["slug"]) - except ValueError: - return HttpResponseNotFound("Invalid ID: ID must be an integer") - - self.object = get_object_or_404(Issue, id=self.kwargs["slug"]) - ipdetails.user = self.request.user - ipdetails.address = get_client_ip(request) - ipdetails.issuenumber = self.object.id - try: - if self.request.user.is_authenticated: - try: - objectget = IP.objects.get(user=self.request.user, issuenumber=self.object.id) - self.object.save() - except: - ipdetails.save() - self.object.views = (self.object.views or 0) + 1 - self.object.save() - else: - try: - objectget = IP.objects.get( - address=get_client_ip(request), issuenumber=self.object.id - ) - self.object.save() - except Exception as e: - print(e) - messages.error(self.request, "That issue was not found 2." + str(e)) - ipdetails.save() - self.object.views = (self.object.views or 0) + 1 - self.object.save() - except Exception as e: - print(e) - messages.error(self.request, "That issue was not found 1." + str(e)) - return redirect("/") - return super(IssueView, self).get(request, *args, **kwargs) - - def get_context_data(self, **kwargs): - context = super(IssueView, self).get_context_data(**kwargs) - if self.object.user_agent: - user_agent = parse(self.object.user_agent) - context["browser_family"] = user_agent.browser.family - context["browser_version"] = user_agent.browser.version_string - context["os_family"] = user_agent.os.family - context["os_version"] = user_agent.os.version_string - context["users_score"] = list( - Points.objects.filter(user=self.object.user) - .aggregate(total_score=Sum("score")) - .values() - )[0] - - if self.request.user.is_authenticated: - context["wallet"] = Wallet.objects.get(user=self.request.user) - context["issue_count"] = Issue.objects.filter(url__contains=self.object.domain_name).count() - context["all_comment"] = self.object.comments.all - context["all_users"] = User.objects.all() - context["likes"] = UserProfile.objects.filter(issue_upvoted=self.object).count() - context["likers"] = UserProfile.objects.filter(issue_upvoted=self.object) - context["dislikes"] = UserProfile.objects.filter(issue_downvoted=self.object).count() - context["dislikers"] = UserProfile.objects.filter(issue_downvoted=self.object) - - context["flags"] = UserProfile.objects.filter(issue_flaged=self.object).count() - context["flagers"] = UserProfile.objects.filter(issue_flaged=self.object) - - context["screenshots"] = IssueScreenshot.objects.filter(issue=self.object).all() - - return context +# class IssueView(DetailView): +# model = Issue +# slug_field = "id" +# template_name = "issue.html" + +# def get(self, request, *args, **kwargs): +# ipdetails = IP() +# try: +# id = int(self.kwargs["slug"]) +# except ValueError: +# return HttpResponseNotFound("Invalid ID: ID must be an integer") + +# self.object = get_object_or_404(Issue, id=self.kwargs["slug"]) +# ipdetails.user = self.request.user +# ipdetails.address = get_client_ip(request) +# ipdetails.issuenumber = self.object.id +# try: +# if self.request.user.is_authenticated: +# try: +# objectget = IP.objects.get(user=self.request.user, issuenumber=self.object.id) +# self.object.save() +# except: +# ipdetails.save() +# self.object.views = (self.object.views or 0) + 1 +# self.object.save() +# else: +# try: +# objectget = IP.objects.get( +# address=get_client_ip(request), issuenumber=self.object.id +# ) +# self.object.save() +# except Exception as e: +# print(e) +# messages.error(self.request, "That issue was not found 2." + str(e)) +# ipdetails.save() +# self.object.views = (self.object.views or 0) + 1 +# self.object.save() +# except Exception as e: +# print(e) +# messages.error(self.request, "That issue was not found 1." + str(e)) +# return redirect("/") +# return super(IssueView, self).get(request, *args, **kwargs) + +# def get_context_data(self, **kwargs): +# context = super(IssueView, self).get_context_data(**kwargs) +# if self.object.user_agent: +# user_agent = parse(self.object.user_agent) +# context["browser_family"] = user_agent.browser.family +# context["browser_version"] = user_agent.browser.version_string +# context["os_family"] = user_agent.os.family +# context["os_version"] = user_agent.os.version_string +# context["users_score"] = list( +# Points.objects.filter(user=self.object.user) +# .aggregate(total_score=Sum("score")) +# .values() +# )[0] + +# if self.request.user.is_authenticated: +# context["wallet"] = Wallet.objects.get(user=self.request.user) +# context["issue_count"] = Issue.objects.filter(url__contains=self.object.domain_name).count() +# context["all_comment"] = self.object.comments.all +# context["all_users"] = User.objects.all() +# context["likes"] = UserProfile.objects.filter(issue_upvoted=self.object).count() +# context["likers"] = UserProfile.objects.filter(issue_upvoted=self.object) +# context["dislikes"] = UserProfile.objects.filter(issue_downvoted=self.object).count() +# context["dislikers"] = UserProfile.objects.filter(issue_downvoted=self.object) + +# context["flags"] = UserProfile.objects.filter(issue_flaged=self.object).count() +# context["flagers"] = UserProfile.objects.filter(issue_flaged=self.object) + +# context["screenshots"] = IssueScreenshot.objects.filter(issue=self.object).all() + +# return context @login_required(login_url="/accounts/login") @@ -3791,6 +3791,95 @@ def get_context_data(self, **kwargs): return context +class IssueView3(DetailView): + model = Issue + slug_field = "id" + template_name = "issue3.html" + + def get(self, request, *args, **kwargs): + ipdetails = IP() + try: + id = int(self.kwargs["slug"]) + except ValueError: + return HttpResponseNotFound("Invalid ID: ID must be an integer") + + self.object = get_object_or_404(Issue, id=self.kwargs["slug"]) + ipdetails.user = self.request.user + ipdetails.address = get_client_ip(request) + ipdetails.issuenumber = self.object.id + try: + if self.request.user.is_authenticated: + try: + objectget = IP.objects.get(user=self.request.user, issuenumber=self.object.id) + self.object.save() + except: + ipdetails.save() + self.object.views = (self.object.views or 0) + 1 + self.object.save() + else: + try: + objectget = IP.objects.get( + address=get_client_ip(request), issuenumber=self.object.id + ) + self.object.save() + except: + ipdetails.save() + self.object.views = (self.object.views or 0) + 1 + self.object.save() + except Exception as e: + print(e) + # TODO: this is only an error for ipv6 currently and doesn't require us to redirect the user - we'll sort this out later + # messages.error(self.request, "That issue was not found."+str(e)) + # return redirect("/") + return super(IssueView3, self).get(request, *args, **kwargs) + + def get_context_data(self, **kwargs): + context = super(IssueView3, self).get_context_data(**kwargs) + if self.object.user_agent: + user_agent = parse(self.object.user_agent) + context["browser_family"] = user_agent.browser.family + context["browser_version"] = user_agent.browser.version_string + context["os_family"] = user_agent.os.family + context["os_version"] = user_agent.os.version_string + context["users_score"] = list( + Points.objects.filter(user=self.object.user) + .aggregate(total_score=Sum("score")) + .values() + )[0] + + if self.request.user.is_authenticated: + context["wallet"] = Wallet.objects.get(user=self.request.user) + context["issue_count"] = Issue.objects.filter(url__contains=self.object.domain_name).count() + context["all_comment"] = self.object.comments.all().order_by("-created_date") + context["all_users"] = User.objects.all() + context["likes"] = UserProfile.objects.filter(issue_upvoted=self.object).count() + context["likers"] = UserProfile.objects.filter(issue_upvoted=self.object) + context["flags"] = UserProfile.objects.filter(issue_flaged=self.object).count() + context["flagers"] = UserProfile.objects.filter(issue_flaged=self.object) + context["more_issues"] = ( + Issue.objects.filter(user=self.object.user) + .exclude(id=self.object.id) + .values("id", "description", "markdown_description", "screenshots__image") + .order_by("views")[:4] + ) + context["subscribed_to_domain"] = False + + if isinstance(self.request.user, User): + context["subscribed_to_domain"] = self.object.domain.user_subscribed_domains.filter( + pk=self.request.user.userprofile.id + ).exists() + + if isinstance(self.request.user, User): + context["bookmarked"] = self.request.user.userprofile.issue_saved.filter( + pk=self.object.id + ).exists() + + context["screenshots"] = IssueScreenshot.objects.filter(issue=self.object).all() + + return context + + + @receiver(user_signed_up) def handle_user_signup(request, user, **kwargs): From 968e0de633bce4e2e5a7c4bc5b4047bece2b9809 Mon Sep 17 00:00:00 2001 From: Bishal <69814108+CodeWithBishal@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:01:31 +0530 Subject: [PATCH 04/14] Update urls.py --- blt/urls.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/blt/urls.py b/blt/urls.py index 40623d619..48df79729 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -31,7 +31,7 @@ UserIssueViewSet, UserProfileViewSet, ) -from website.views import ( +from website.views import ( # IssueView, AllIssuesView, CompanySettings, ContributorStatsView, @@ -53,7 +53,6 @@ InboundParseWebhookView, InviteCreate, IssueCreate, - # IssueView, IssueView2, IssueView3, JoinCompany, From ce82313fe5034778058ac0b7eda895a51cb7e428 Mon Sep 17 00:00:00 2001 From: Bishal <69814108+CodeWithBishal@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:23:44 +0530 Subject: [PATCH 05/14] file formatted for precommit checks --- blt/settings.py | 1 + scripts/git_username_replacer.py | 10 ++++---- website/templates/issue3.html | 44 +++++++++++++++----------------- website/views.py | 3 +-- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/blt/settings.py b/blt/settings.py index 3f801baa1..9446610a9 100644 --- a/blt/settings.py +++ b/blt/settings.py @@ -6,6 +6,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/ref/settings/ """ + # from google.oauth2 import service_account import os import socket diff --git a/scripts/git_username_replacer.py b/scripts/git_username_replacer.py index b965ff8f3..71c83ed0d 100644 --- a/scripts/git_username_replacer.py +++ b/scripts/git_username_replacer.py @@ -1,9 +1,9 @@ """ - Git Username Replacer: - Safeguard user privacy and enhance security by easily replacing usernames in Git commit history. - Protect sensitive information with our tool. - - Use: python git_username_replacer.py +Git Username Replacer: +Safeguard user privacy and enhance security by easily replacing usernames in Git commit history. +Protect sensitive information with our tool. + +Use: python git_username_replacer.py """ import argparse diff --git a/website/templates/issue3.html b/website/templates/issue3.html index 85e767041..05d357bef 100644 --- a/website/templates/issue3.html +++ b/website/templates/issue3.html @@ -1,32 +1,28 @@ {% extends "base.html" %} {% load custom_tags %} {% block metaTags %} - - {% block title %} BLT Issue - {{ object.description }} {% endblock title %} - - -{% if object.user.username %} - - -{% else %} - - -{% endif %} - -{% for screenshot in screenshots %} - -{% endfor %} - - + + {% block title %} BLT Issue - {{ object.description }} {% endblock title %} + + + {% if object.user.username %} + + {% else %} + + {% endif %} + + {% for screenshot in screenshots %} + + {% endfor %} + + -{% comment %} TODO: change to update {% endcomment %} - - + {% comment %} TODO: change to update {% endcomment %} + + - - - - + + {% endblock metaTags %} {% load static %} {% load gravatar %} diff --git a/website/views.py b/website/views.py index 7e587fc86..17d3ab93f 100644 --- a/website/views.py +++ b/website/views.py @@ -3791,6 +3791,7 @@ def get_context_data(self, **kwargs): return context + class IssueView3(DetailView): model = Issue slug_field = "id" @@ -3879,8 +3880,6 @@ def get_context_data(self, **kwargs): return context - - @receiver(user_signed_up) def handle_user_signup(request, user, **kwargs): referral_token = request.session.get("ref") From 693c89515b34a7759741323ebdec862368c83212 Mon Sep 17 00:00:00 2001 From: Bishal <69814108+CodeWithBishal@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:30:02 +0530 Subject: [PATCH 06/14] djlint pre commit passed --- website/templates/base.html | 40 ++++---- website/templates/issue3.html | 186 +++++++++++----------------------- 2 files changed, 81 insertions(+), 145 deletions(-) diff --git a/website/templates/base.html b/website/templates/base.html index 630c43ac0..b23d5eb2d 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -12,26 +12,26 @@ {% block metaTags %} - - {% block title %} - {% env 'PROJECT_NAME' %} - {% endblock title %} - - - - - - - - - - + + {% block title %} + {% env 'PROJECT_NAME' %} + {% endblock title %} + + + + + + + + + + {% endblock metaTags %} - {% block title %} BLT Issue - {{ object.description }} {% endblock title %} - - - {% if object.user.username %} + + {% block title %} + BLT Issue - {{ object.description }} + {% endblock title %} + + + {% if object.user.username %} - {% else %} + {% else %} - {% endif %} - - {% for screenshot in screenshots %} - - {% endfor %} - - - - {% comment %} TODO: change to update {% endcomment %} - - - - - + {% endif %} + + {% for screenshot in screenshots %} + + {% endfor %} + + + {% comment %} TODO: change to update {% endcomment %} + + + + {% endblock metaTags %} {% load static %} {% load gravatar %} @@ -33,11 +39,10 @@ crossorigin="anonymous"> {% endblock head %} {% block content %} -{% include "includes/sidenav.html" %} -
- - Lorem ipsum dolor sit amet consectetur adipisicing elit. Suscipit inventore provident dolorum et, in dolorem maxime explicabo praesentium doloribus officiis laboriosam iusto laudantium! Ad architecto dolor cumque perferendis quidem libero doloremque nam quo, molestias repellat, nobis vitae porro veritatis non voluptatibus. Eaque beatae cumque illo quo nulla quisquam, recusandae earum distinctio voluptatibus delectus facilis quae reiciendis mollitia nobis, dolor itaque unde explicabo natus? Itaque doloribus nihil ducimus praesentium repellendus quis quasi cupiditate dicta inventore assumenda optio eveniet numquam labore odio provident blanditiis maiores veritatis, placeat explicabo reprehenderit facere aspernatur distinctio vero. Quae a corporis expedita quis provident iure ut asperiores. -
+ {% include "includes/sidenav.html" %} +
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Suscipit inventore provident dolorum et, in dolorem maxime explicabo praesentium doloribus officiis laboriosam iusto laudantium! Ad architecto dolor cumque perferendis quidem libero doloremque nam quo, molestias repellat, nobis vitae porro veritatis non voluptatibus. Eaque beatae cumque illo quo nulla quisquam, recusandae earum distinctio voluptatibus delectus facilis quae reiciendis mollitia nobis, dolor itaque unde explicabo natus? Itaque doloribus nihil ducimus praesentium repellendus quis quasi cupiditate dicta inventore assumenda optio eveniet numquam labore odio provident blanditiis maiores veritatis, placeat explicabo reprehenderit facere aspernatur distinctio vero. Quae a corporis expedita quis provident iure ut asperiores. +
{% comment %}
@@ -57,18 +62,8 @@