+
+
+
+ {% for project in projects %}
+
+
+ {% if project.logo %}
+

{% else %}
-

+
+ No Logo
+
{% endif %}
-
{{ user.user.username }}
+
+
+ {% if project.description %}
+
{{ project.description|truncatechars:150 }}
+ {% endif %}
+
+ {% if project.url %}
+
+
+ {{ project.url }}
+
+ {% endif %}
+ {% if project.twitter %}
+
+
+
+ {% endif %}
+ {% if project.facebook %}
+
+
+
+ {% endif %}
+
+
-
-
- {% if user.total_score is None %}
-
0 Point
+
+ {% if project.organization %}
+ {% if project.organization.logo %}
+

+ {% endif %}
+
+ Organization:
+ {{ project.organization.name }}
+
+ {% else %}
+
+ Organization: Not Assigned
+
+ {% endif %}
+
+
+
+ Visits: {{ project.project_visit_count }}
+
+
+ Created: {{ project.created|date:"F j, Y" }}
+
+
+ Modified: {{ project.modified|date:"F j, Y" }}
+
+
+ {% if project.tags.all %}
+
+ {% for tag in project.tags.all %}
+
+ {{ tag.name }}
+
+ {% endfor %}
+
+ {% endif %}
+
+ {% endfor %}
+
+
+
+ {% endif %}
+ {% if tags %}
+
+
+
+
+ {% if matching_organizations %}
+
+
+ Matching Organizations
+
+
+ {% for org in matching_organizations %}
+
+ {% if org.logo %}
+

+ {% endif %}
+
{{ org.name }}
+
+ {% endfor %}
+
+
+ {% endif %}
+ {% if matching_domains %}
+
+
+ Matching Domains
+
+
+ {% for domain in matching_domains %}
+
+ {% if domain.logo %}
+

+ {% endif %}
+
{{ domain.name }}
+
+ {% endfor %}
+
+
+ {% endif %}
+ {% if matching_issues %}
+
+
+ Matching Issues
+
+
+ {% for issue in matching_issues %}
+
+ {% if issue.logo %}
+

+ {% endif %}
+
{{ issue.description }}
+
+ {% endfor %}
+
+
+ {% endif %}
+ {% if matching_user_profiles %}
+
+
+ Matching User Profiles
+
+
+ {% for profile in matching_user_profiles %}
+
+ {% if profile.user_avatar %}
+

+ {% else %}
+

+ {% endif %}
+
{{ profile.user.username }}
+
+ {% endfor %}
+
+
+ {% endif %}
+ {% if matching_repos %}
+
+
+ Matching Repositories
+
+
+ {% for repo in matching_repos %}
+
+ {% endfor %}
+
+
+ {% endif %}
+
+
+ {% endif %}
+ {% if repos %}
+
+
+
+
+ {% for repo in repos %}
+
+
+ {% if repo.logo_url %}
+

{% else %}
-
{{ user.total_score|floatformat:0 }} Points
+
+ No Logo
+
{% endif %}
+
+
+ {% if repo.description %}
{{ repo.description|truncatechars:150 }}
{% endif %}
+
+ {% if repo.primary_language %}
+ {{ repo.primary_language }}
+ {% endif %}
+ {% if repo.stars %}
+
+
+ {{ repo.stars }}
+
+ {% endif %}
+ {% if repo.forks %}
+
+
+ {{ repo.forks }}
+
+ {% endif %}
+ {% if repo.open_issues %}
+
+
+ {{ repo.open_issues }}
+
+ {% endif %}
+
+
+
+
+
+
+ Last Updated:
+ {{ repo.last_updated|date:"d M Y, H:i" }}
+
+
+
+ License:
+ {{ repo.license }}
+
+
+
+ Visits:
+ {{ repo.repo_visit_count }}
+
-
View Profile
+ {% if repo.tags.all %}
+
+ {% for tag in repo.tags.all %}
+
+ {{ tag.name }}
+
+ {% endfor %}
+
+ {% endif %}
{% endfor %}
- {% else %}
-
+ {% endif %}
+ {% if not issues and not domains and not users and not organizations and not projects and not tags and not repos %}
+
+
+ {% endif %}
{% endif %}
{% endblock content %}
diff --git a/website/views/core.py b/website/views/core.py
index e89f1aa79..4a6079c3a 100644
--- a/website/views/core.py
+++ b/website/views/core.py
@@ -37,9 +37,14 @@
Badge,
Domain,
Issue,
+ Organization,
PRAnalysisReport,
+ Project,
+ Repo,
Suggestion,
SuggestionVotes,
+ Tag,
+ UserBadge,
UserProfile,
Wallet,
)
@@ -300,24 +305,13 @@ def find_key(request, token):
def search(request, template="search.html"):
query = request.GET.get("query")
- stype = request.GET.get("type")
+ stype = request.GET.get("type", "organizations")
context = None
if query is None:
return render(request, template)
query = query.strip()
- if query[:6] == "issue:":
- stype = "issue"
- query = query[6:]
- elif query[:7] == "domain:":
- stype = "domain"
- query = query[7:]
- elif query[:5] == "user:":
- stype = "user"
- query = query[5:]
- elif query[:6] == "label:":
- stype = "label"
- query = query[6:]
- if stype == "issue" or stype is None:
+
+ if stype == "issues":
context = {
"query": query,
"type": stype,
@@ -325,21 +319,26 @@ def search(request, template="search.html"):
Q(is_hidden=True) & ~Q(user_id=request.user.id)
)[0:20],
}
- elif stype == "domain":
+ elif stype == "domains":
context = {
"query": query,
"type": stype,
"domains": Domain.objects.filter(Q(url__icontains=query), hunt=None)[0:20],
}
- elif stype == "user":
+ elif stype == "users":
+ users = (
+ UserProfile.objects.filter(Q(user__username__icontains=query))
+ .annotate(total_score=Sum("user__points__score"))
+ .order_by("-total_score")[0:20]
+ )
+ for userprofile in users:
+ userprofile.badges = UserBadge.objects.filter(user=userprofile.user)
context = {
"query": query,
"type": stype,
- "users": UserProfile.objects.filter(Q(user__username__icontains=query))
- .annotate(total_score=Sum("user__points__score"))
- .order_by("-total_score")[0:20],
+ "users": users,
}
- elif stype == "label":
+ elif stype == "labels":
context = {
"query": query,
"type": stype,
@@ -347,7 +346,61 @@ def search(request, template="search.html"):
Q(is_hidden=True) & ~Q(user_id=request.user.id)
)[0:20],
}
+ elif stype == "organizations":
+ organizations = Organization.objects.filter(name__icontains=query)
+ for org in organizations:
+ d = Domain.objects.filter(organization=org).first()
+ if d:
+ org.absolute_url = d.get_absolute_url()
+ context = {
+ "query": query,
+ "type": stype,
+ "organizations": Organization.objects.filter(name__icontains=query),
+ }
+ elif stype == "projects":
+ context = {
+ "query": query,
+ "type": stype,
+ "projects": Project.objects.filter(
+ Q(name__icontains=query) | Q(description__icontains=query)
+ ),
+ }
+ elif stype == "repos":
+ context = {
+ "query": query,
+ "type": stype,
+ "repos": Repo.objects.filter(
+ Q(name__icontains=query) | Q(description__icontains=query)
+ ),
+ }
+ elif stype == "tags":
+ tags = Tag.objects.filter(name__icontains=query)
+ matching_organizations = Organization.objects.filter(tags__in=tags).distinct()
+ matching_domains = Domain.objects.filter(tags__in=tags).distinct()
+ matching_issues = Issue.objects.filter(tags__in=tags).distinct()
+ matching_user_profiles = UserProfile.objects.filter(tags__in=tags).distinct()
+ matching_repos = Repo.objects.filter(tags__in=tags).distinct()
+ for org in matching_organizations:
+ d = Domain.objects.filter(organization=org).first()
+ if d:
+ org.absolute_url = d.get_absolute_url()
+ context = {
+ "query": query,
+ "type": stype,
+ "tags": tags,
+ "matching_organizations": matching_organizations,
+ "matching_domains": matching_domains,
+ "matching_issues": matching_issues,
+ "matching_user_profiles": matching_user_profiles,
+ "matching_repos": matching_repos,
+ }
+ elif stype == "languages":
+ context = {
+ "query": query,
+ "type": stype,
+ "repos": Repo.objects.filter(primary_language__icontains=query),
+ }
if request.user.is_authenticated:
context["wallet"] = Wallet.objects.get(user=request.user)
return render(request, template, context)
From 8dc96e604581b4b5b2a970adbe69c920db9e17e4 Mon Sep 17 00:00:00 2001
From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com>
Date: Thu, 23 Jan 2025 22:33:54 -0500
Subject: [PATCH 2/2] Update slack_handlers.py
---
website/views/slack_handlers.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/website/views/slack_handlers.py b/website/views/slack_handlers.py
index 7d2f8e62c..182768b43 100644
--- a/website/views/slack_handlers.py
+++ b/website/views/slack_handlers.py
@@ -262,7 +262,7 @@ def slack_commands(request):
"type": "section",
"text": {
"type": "mrkdwn",
- "text": " 🛠*GSOC Projects:* View this year's participating GSOC projects .",
+ "text": " 🛠*GSOC Projects:* View this year's participating GSOC projects https://owasp.org/www-community/initiatives/gsoc/gsoc2025ideas",
},
},
{"type": "divider"},