Skip to content

Commit

Permalink
Merge branch 'main' into update_issue2
Browse files Browse the repository at this point in the history
  • Loading branch information
DonnieBLT authored Feb 15, 2024
2 parents 7d36df7 + 86e591c commit 7319d9c
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 39 deletions.
4 changes: 3 additions & 1 deletion company/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.urls import include, path
from django.contrib.auth.decorators import login_required

from company.views import (
CompanyDashboardAnalyticsView,
CompanyDashboardManageBugsView,
Expand Down Expand Up @@ -26,5 +28,5 @@
path("dashboard/end_bughunt/<int:pk>",EndBughuntView.as_view(),name="end_bughunt"),
path("<str:company>/dashboard/add_bughunt/",AddHuntView.as_view(),name="add_bughunt"),
path("<str:company>/dashboard/add_domain/",AddDomainView.as_view(),name="add_domain"),
path("domain/<int:pk>/",DomainView.as_view(),name="view_domain"),
path("domain/<int:pk>/", login_required(DomainView.as_view()),name="view_domain"),
]
24 changes: 14 additions & 10 deletions company/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,20 +551,24 @@ def get(self,request,pk,*args,**kwargs):
total_bug_reported = Issue.objects.filter(pk=domain["id"]).count()
total_bug_accepted = Issue.objects.filter(pk=domain["id"], verified=True).count()

# get latest reported public issues
latest_issues = (
Issue.objects
.values("id","domain__name","url","description","user__id","user__username","user__userprofile__user_avatar","label","status","verified","rewarded","created__day","created__month","created__year")
.filter(domain__id=domain["id"],is_hidden=False).order_by("-created")
[:11]
)
is_domain_manager = Domain.objects.filter(
Q(id=domain["id"]) &
Q(managers__in=[request.user])
).exists()
if not is_domain_manager:
latest_issues.filter(is_hidden=False) #show public issues to normal users

if is_domain_manager:
latest_issues = (
Issue.objects
.values("id","domain__name","url","description","user__id","user__username","user__userprofile__user_avatar","label","status","verified","rewarded","created__day","created__month","created__year")
.filter(domain__id=domain["id"]).order_by("-created")
[:11]
)
else :
latest_issues = (
Issue.objects
.values("id","domain__name","url","description","user__id","user__username","user__userprofile__user_avatar","label","status","verified","rewarded","created__day","created__month","created__year")
.filter(domain__id=domain["id"],is_hidden=False).order_by("-created")
[:11]
)
issue_labels = [label[-1] for label in Issue.labels]
cleaned_issues = []
for issue in latest_issues:
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

134 changes: 107 additions & 27 deletions website/templates/includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,38 @@
color: black;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {
const desktopDropdownButton = document.getElementById('dropdownButton');
const desktopDropdownMenu = document.getElementById('dropdownMenu');

<nav class="fixed top-0 z-50 w-full bg-white border-b border-[#F7F7F7] border-b-2 px-4">
if (desktopDropdownButton && desktopDropdownMenu) {
desktopDropdownButton.addEventListener('click', () => {
desktopDropdownMenu.classList.toggle('hidden');
});
document.addEventListener('click', (e) => {
if (!desktopDropdownButton.contains(e.target) && !desktopDropdownMenu.contains(e.target)) {
desktopDropdownMenu.classList.add('hidden');
}
});
}

const mobileDropdownButton = document.getElementById('dropdown-toggle-mobile');
const mobileDropdownMenu = document.getElementById('dropdown-mobile');
if (mobileDropdownButton && mobileDropdownMenu) {
mobileDropdownButton.addEventListener('click', () => {
mobileDropdownMenu.classList.toggle('hidden');
});
document.addEventListener('click', (e) => {
if (!mobileDropdownButton.contains(e.target) && !mobileDropdownMenu.contains(e.target)) {
mobileDropdownMenu.classList.add('hidden');
}
});
}
});
</script>

<nav class="fixed top-0 z-50 w-full bg-white border-b border-[#F7F7F7] border-b-2 px-4" style="height: 10%;">
<div class="px-3 py-3 lg:px-5 lg:pl-3">
<div class="flex items-center justify-between">
<div class="flex items-center justify-start rtl:justify-end">
Expand Down Expand Up @@ -48,39 +78,89 @@
</a>
</div>

<!-- User Avatar -->
{% if request.user.is_authenticated %}
<a href="/accounts/logout" id="user" class="relative flex row items-center gap-3 mr-[30px] hover:no-underline inline-block">
{% if request.user.userprofile.avatar %}
<img src="{{ request.user.userprofile.avatar }}" class="h-[30px] w-[30px] rounded-full ">
{% elif request.user.socialaccount_set.all.0.get_avatar_url %}
<img src="{{ request.user.socialaccount_set.all.0.get_avatar_url }}"
class="h-[30px] w-[30px] rounded-full ">
{% else %}
{% gravatar request.user.email 30 '' 'gravatar rounded-full' %}
{% endif %}
<span
class="text-[1.6rem] font-[600]"><span
class="">{{ request.user.username }}</span> ({{ request.user|score|default:"0" }} Pts)
</span>
</a>
<li class="h-[80px] flex justify-center items-center ">
<button id="dropdownButton" class="relative flex items-center sm:gap-3 mr-[30px]" type="button">
{% if request.user.userprofile.avatar %}
<img src="{{ request.user.userprofile.avatar }}" class="h-[30px] w-[30px] rounded-full ">
{% elif request.user.socialaccount_set.all.0.get_avatar_url %}
<img src="{{ request.user.socialaccount_set.all.0.get_avatar_url }}"
class="h-[30px] w-[30px] rounded-full ">
{% else %}
{% gravatar request.user.email 30 '' 'gravatar rounded-full' %}
{% endif %}
<span
class="absolute -right-[17px] -bottom-[25px] lg:-right-[25px] lg:-bottom-[25px] sm:static whitespace-nowrap"><span
class="">{{ request.user.username }}</span> ({{ request.user|score|default:"0" }} Pts)
<i class="fa fa-caret-down text-red-500"></i>
</span>
</button>
<!-- Dropdown for User Avatar -->
<div id="dropdownMenu" class="z-50 hidden absolute bg-white top-32 right-5">
<ul class="flex flex-col gap-2 px-8 py-4 border shadow-xl rounded-lg left-auto">
<li>
<a href="/accounts/profile/">
<i class="fa fa-user fa-fw"></i> {% trans "User Profile" %}
</a>
</li>
<li>
<a href="{% env 'EXTENSION_URL' %}" target="_new">
<i class="fa fa-chrome fa-fw"></i>
{% trans "Add to chrome" %}
</a>
</li>
<li>
<a href="/start">
<i class="fa fa-play fa-fw"></i> {% trans "Start a Bug Hunt" %}
</a>
</li>
<li>
<a href="/social">
<i class="fa fa-share fa-fw"></i>
{% trans "Social" %}
</a>
</li>
<li>
<a href="/accounts/password/change/">
<i class="fa fa-gear fa-fw"></i> {% trans "Change Password" %}
</a>
</li>
<li>
<a href="/invite/">
<i class="fa fa-paper-plane fa-fw"></i> {% trans "Invite Friends" %}
</a>
</li>
<li>
<a href="{% url 'company_view' %}">
<i class="fa fa-building fa-fw"></i> {% trans "Company Dashboard" %}
</a>
</li>
<!-- divider -->
<li class="border my-4 -mx-8"></li>
<li>
<a href="/accounts/logout/">
<i class="fa fa-sign-out fa-fw"></i> {% trans "Logout" %}
</a>
</li>
</ul>
</div>
</li>
{% else %}


<!-- Sign up and Log in Buttons -->
<div class="flex column items-center gap-[8px]">
<div class="lg:!flex h-[80px] justify-center items-center">
<a href="/accounts/signup"
class="lg:!inline-block bg-red-500 hover:bg-red-600 h-[38px] py-[8px] px-[25px] whitespace-nowrap !text-2xl font-bold text-white leading-[21px] cursor-pointer hover:text-white hover:no-underline rounded-xl tracking-wide">
{% trans "Signup" %}
</a>
<a href="/accounts/login"
class="lg:!inline-block bg-red-500 hover:bg-red-600 h-[38px] py-[8px] px-[25px] whitespace-nowrap !text-2xl font-bold text-white leading-[21px] cursor-pointer hover:text-white hover:no-underline rounded-xl tracking-wide">
{% trans "Login" %}
</a>
class="h-[38px] px-[25px] py-[9px] bg-red-500 hover:bg-red-600 hover:no-underline text-white font-bold text-2xl mr-[20px] hover:text-white">
{% trans "Signup" %}</a>
<a href="/accounts/login" data-toggle="modal"
class="h-[38px] px-[25px] py-[9px] bg-red-500 hover:bg-red-600 hover:no-underline text-white font-bold text-2xl mr-[20px] hover:text-white">
{%trans "Login" %}</a>
</div>
<!-- Log in icon -->
<a href="/accounts/login" class="block sm:hidden mr-[30px]">
<i class="fa fa-user !text-5xl text-red-500"></i>
</a>
{% endif %}


</div>
</div>
</nav>

0 comments on commit 7319d9c

Please sign in to comment.