diff --git a/blt/settings.py b/blt/settings.py index 831b6e1cc..5f38ebacc 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/blt/urls.py b/blt/urls.py index a1a228b79..1e8b6ce13 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -31,7 +31,7 @@ UserIssueViewSet, UserProfileViewSet, ) -from website.views import ( +from website.views import ( # TODO IssueView,; TODO: REMOVE like_issue2 etc AllIssuesView, CompanySettings, ContributorStatsView, @@ -55,6 +55,7 @@ IssueCreate, IssueView, IssueView2, + IssueView3, JoinCompany, ListHunts, OngoingHunts, @@ -70,11 +71,14 @@ UserProfileDetailView, contributors_view, dislike_issue2, + dislike_issue3, facebook_callback, flag_issue2, + flag_issue3, github_callback, google_callback, like_issue2, + like_issue3, subscribe_to_domains, vote_count, ) @@ -264,6 +268,7 @@ name="user_profile", ), path(settings.ADMIN_URL + "/", admin.site.urls), + # TODO: REMOVE after _3 is ready re_path(r"^like_issue/(?P\d+)/$", website.views.like_issue, name="like_issue"), re_path( r"^dislike_issue/(?P\d+)/$", @@ -274,6 +279,9 @@ re_path(r"^like_issue2/(?P\d+)/$", like_issue2, name="like_issue2"), re_path(r"^dislike_issue2/(?P\d+)/$", dislike_issue2, name="dislike_issue2"), re_path(r"^flag_issue2/(?P\d+)/$", flag_issue2, name="flag_issue2"), + re_path(r"^like_issue3/(?P\d+)/$", like_issue3, name="like_issue3"), + re_path(r"^dislike_issue3/(?P\d+)/$", dislike_issue3, name="dislike_issue3"), + re_path(r"^flag_issue3/(?P\d+)/$", flag_issue3, name="flag_issue3"), re_path(r"^vote_count/(?P\d+)/$", vote_count, name="vote_count"), path("domain//subscribe/", subscribe_to_domains, name="subscribe_to_domains"), re_path(r"^save_issue/(?P\d+)/$", website.views.save_issue, name="save_issue"), @@ -301,8 +309,10 @@ ), # delete_comment path("issue2/comment/delete/", website.views.delete_comment, name="delete_comment"), + # TODO: REMOVE after _3 is ready 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 21f82ac6c..6781691ff 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/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/base.html b/website/templates/base.html index eb72cad69..356dcc077 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -8,29 +8,34 @@ - - {% block title %} - {% env 'PROJECT_NAME' %} - {% endblock title %} - - - - + {% block metaTags %} + + {% block title %} + {% env 'PROJECT_NAME' %} + {% endblock title %} + + + + + + + + + + + {% endblock metaTags %} - - - - @@ -84,6 +89,7 @@ } {% include "includes/header.html" %} + {% comment %}
{% endcomment %}
{% block content %} {% endblock content %} diff --git a/website/templates/includes/_bookmark3.html b/website/templates/includes/_bookmark3.html new file mode 100644 index 000000000..ad0d1cdc1 --- /dev/null +++ b/website/templates/includes/_bookmark3.html @@ -0,0 +1,54 @@ +{% if request.user.is_authenticated %} + +{% else %} + +{% endif %} + diff --git a/website/templates/includes/_dislikes3.html b/website/templates/includes/_dislikes3.html new file mode 100644 index 000000000..5b361329f --- /dev/null +++ b/website/templates/includes/_dislikes3.html @@ -0,0 +1,36 @@ +{% if request.user.is_authenticated %} +
+ +
+{% else %} + +{% endif %} + diff --git a/website/templates/includes/_flags3.html b/website/templates/includes/_flags3.html new file mode 100644 index 000000000..39348f286 --- /dev/null +++ b/website/templates/includes/_flags3.html @@ -0,0 +1,40 @@ +{% if request.user.is_authenticated %} +
+ +
+{% else %} + +{% endif %} + diff --git a/website/templates/includes/_like_dislike_share.html b/website/templates/includes/_like_dislike_share.html new file mode 100644 index 000000000..4698f28cb --- /dev/null +++ b/website/templates/includes/_like_dislike_share.html @@ -0,0 +1,24 @@ +{% load gravatar %} + diff --git a/website/templates/includes/_likes3.html b/website/templates/includes/_likes3.html new file mode 100644 index 000000000..b7510ad94 --- /dev/null +++ b/website/templates/includes/_likes3.html @@ -0,0 +1,40 @@ +{% if request.user.is_authenticated %} +
+ +
+{% else %} + +{% endif %} + diff --git a/website/templates/issue3.html b/website/templates/issue3.html new file mode 100644 index 000000000..a29ba2c63 --- /dev/null +++ b/website/templates/issue3.html @@ -0,0 +1,257 @@ +{% extends "base.html" %} +{% load custom_tags %} +{% block metaTags %} + + {% block title %} + BLT Issue - {{ object.description|escapejs }} + {% endblock title %} + + + {% if object.user.username %} + + {% else %} + + {% endif %} + + {% for screenshot in screenshots %} + + {% endfor %} + + + {% comment %} TODO: change to update DOMAIN {% endcomment %} + + + + +{% endblock metaTags %} +{% load static %} +{% load gravatar %} +{% load custom_tags %} +{% block head %} + +{% endblock head %} +{% block content %} + {% include "includes/sidenav.html" %} + {% comment %} TODO: + delete these files after final is ready + {% include "includes/_likes2.html" %} + {% include "includes/_dislike2.html" %} + {% include "includes/_flags2.html" %} + {% include "includes/_bookmark2.html" %} + {% endcomment %} + {% include "includes/_like_dislike_share.html" %} +
+

{{ object.description | truncatechars:100|escapejs }}

+

+ {{ object.url | truncatechars:100 }} +

+
+
+
+
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo vero incidunt reprehenderit illo tenetur numquam hic ut optio esse eos minus dignissimos ducimus officia ab quidem quis, corrupti tempore voluptates. +
+
+
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo vero incidunt reprehenderit illo tenetur numquam hic ut optio esse eos minus dignissimos ducimus officia ab quidem quis, corrupti tempore voluptates. +
+
+
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo vero incidunt reprehenderit illo tenetur numquam hic ut optio esse eos minus dignissimos ducimus officia ab quidem quis, corrupti tempore voluptates. +
+
+
+
+
+

Issue Description

+

{{ object.markdown_description|escapejs }}

+
+ + + + +{% endblock content %} diff --git a/website/views.py b/website/views.py index 6a884d7f7..e06b9d994 100644 --- a/website/views.py +++ b/website/views.py @@ -1895,6 +1895,7 @@ def get_success_url(self): return "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HH7MNY6KJGZFW" +# TODO: REMOVE after _3 is ready class IssueView(DetailView): model = Issue slug_field = "id" @@ -2199,6 +2200,7 @@ def follow_user(request, user): return HttpResponse("Success") +# TODO: remove after _3 is ready @login_required(login_url="/accounts/login") def like_issue(request, issue_pk): context = {} @@ -3591,6 +3593,7 @@ def get_context_data(self, **kwargs): return context +# TODO: Remove like_issue2 and like_issue, dislike_issue,dislike_issue2,flag_issue2,flag_issue after ready @login_required(login_url="/accounts/login") def flag_issue2(request, issue_pk): context = {} @@ -3676,6 +3679,98 @@ def dislike_issue2(request, issue_pk): return render(request, "includes/_dislike2.html", context) +@login_required(login_url="/accounts/login") +def flag_issue3(request, issue_pk): + context = {} + issue_pk = int(issue_pk) + issue = Issue.objects.get(pk=issue_pk) + userprof = UserProfile.objects.get(user=request.user) + if userprof in UserProfile.objects.filter(issue_flaged=issue): + userprof.issue_flaged.remove(issue) + else: + userprof.issue_flaged.add(issue) + issue_pk = issue.pk + + userprof.save() + total_flag_votes = UserProfile.objects.filter(issue_flaged=issue).count() + context["object"] = issue + context["flags"] = total_flag_votes + context["isFlagged"] = UserProfile.objects.filter( + issue_flaged=issue, user=request.user + ).exists() + return render(request, "includes/_flags3.html", context) + + +@login_required(login_url="/accounts/login") +def like_issue3(request, issue_pk): + context = {} + issue_pk = int(issue_pk) + issue = get_object_or_404(Issue, pk=issue_pk) + userprof = UserProfile.objects.get(user=request.user) + + if UserProfile.objects.filter(issue_downvoted=issue, user=request.user).exists(): + userprof.issue_downvoted.remove(issue) + if UserProfile.objects.filter(issue_upvoted=issue, user=request.user).exists(): + userprof.issue_upvoted.remove(issue) + else: + userprof.issue_upvoted.add(issue) + liked_user = issue.user + liker_user = request.user + issue_pk = issue.pk + msg_plain = render_to_string( + "email/issue_liked.txt", + { + "liker_user": liker_user.username, + "liked_user": liked_user.username, + "issue_pk": issue_pk, + }, + ) + msg_html = render_to_string( + "email/issue_liked.txt", + { + "liker_user": liker_user.username, + "liked_user": liked_user.username, + "issue_pk": issue_pk, + }, + ) + + send_mail( + "Your issue got an upvote!!", + msg_plain, + settings.EMAIL_TO_STRING, + [liked_user.email], + html_message=msg_html, + ) + + total_votes = UserProfile.objects.filter(issue_upvoted=issue).count() + context["object"] = issue + context["likes"] = total_votes + context["isLiked"] = UserProfile.objects.filter(issue_upvoted=issue, user=request.user).exists() + return render(request, "includes/_likes3.html", context) + + +@login_required(login_url="/accounts/login") +def dislike_issue3(request, issue_pk): + context = {} + issue_pk = int(issue_pk) + issue = get_object_or_404(Issue, pk=issue_pk) + userprof = UserProfile.objects.get(user=request.user) + + if UserProfile.objects.filter(issue_upvoted=issue, user=request.user).exists(): + userprof.issue_upvoted.remove(issue) + if UserProfile.objects.filter(issue_downvoted=issue, user=request.user).exists(): + userprof.issue_downvoted.remove(issue) + else: + userprof.issue_downvoted.add(issue) + total_votes = UserProfile.objects.filter(issue_downvoted=issue).count() + context["object"] = issue + context["dislikes"] = total_votes + context["isDisliked"] = UserProfile.objects.filter( + issue_downvoted=issue, user=request.user + ).exists() + return render(request, "includes/_dislikes3.html", context) + + @login_required(login_url="/accounts/login") def vote_count(request, issue_pk): issue_pk = int(issue_pk) @@ -3795,6 +3890,104 @@ 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["isLiked"] = UserProfile.objects.filter( + issue_upvoted=self.object, user=self.request.user + ).exists() + context["isDisliked"] = UserProfile.objects.filter( + issue_downvoted=self.object, user=self.request.user + ).exists() + context["isFlagged"] = UserProfile.objects.filter( + issue_flaged=self.object, user=self.request.user + ).exists() + 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["dislikes"] = UserProfile.objects.filter(issue_downvoted=self.object).count() + context["likers"] = UserProfile.objects.filter(issue_upvoted=self.object).all() + 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): referral_token = request.session.get("ref")