Skip to content

Commit

Permalink
Merge branch 'main' into activity-feed
Browse files Browse the repository at this point in the history
  • Loading branch information
DonnieBLT authored Nov 24, 2024
2 parents 7127b55 + 0cc0127 commit 77b0d4a
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 52 deletions.
58 changes: 58 additions & 0 deletions website/migrations/0154_contributors_to_users_20241123_1836.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 5.1.3 on 2024-11-23 18:36

from django.db import migrations


def add_contributor_tag(apps, schema_editor):
# Get the models dynamically to avoid dependency issues
User = apps.get_model("auth", "User")
UserProfile = apps.get_model("website", "UserProfile")
Tag = apps.get_model("website", "Tag")

# Get or create the "contributor" tag
contributor_tag, _ = Tag.objects.get_or_create(name="BLT-Contributors", slug="BLT-Contributors")

# Add the tag to specific users
usernames = [
"jajodiaraghav",
"CodeWithBishal",
"amrit",
"mohit",
"souravbadami",
"goyal-sidd",
"neethu",
"donnie",
"ankit2001",
"mrigank",
"Kej-r03",
"bhawna",
"shubham",
"Tarachris",
"Jisan",
"radac",
"akankshsinha",
"justary27",
]

for username in usernames:
try:
user = User.objects.get(username=username)
user_profile = UserProfile.objects.get(user=user)
user_profile.tags.add(contributor_tag)
except User.DoesNotExist:
print(f"User '{username}' does not exist.")
except UserProfile.DoesNotExist:
print(f"UserProfile for '{username}' does not exist.")


class Migration(migrations.Migration):
dependencies = [
(
"website",
"0153_delete_contributorstats",
), # Update with the correct last migration in your app
]

operations = [
migrations.RunPython(add_contributor_tag),
]
4 changes: 4 additions & 0 deletions website/templates/account/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h3 class="my-4 text-2xl font-semibold text-gray-700">{% trans "Account SignUp"
type="text"
id="id_username"
name="username"
value="{{ form.username.value|default:'' }}"
class="px-4 py-2 w-[100%] h-[28px] transition duration-300 border border-gray-300 rounded focus:border-transparent focus:outline-none focus:ring-4 focus:ring-red-200" />
<span class="help-block">{{ form.username.errors }}</span>
</div>
Expand All @@ -40,6 +41,7 @@ <h3 class="my-4 text-2xl font-semibold text-gray-700">{% trans "Account SignUp"
<input type="email"
id="id_email"
name="email"
value="{{ form.email.value|default:'' }}"
class="px-4 py-2 w-[100%] h-[28px] transition duration-300 border border-gray-300 rounded focus:border-transparent focus:outline-none focus:ring-4 focus:ring-red-200" />
<span class="help-block">{{ form.email.errors }}</span>
</div>
Expand All @@ -50,6 +52,7 @@ <h3 class="my-4 text-2xl font-semibold text-gray-700">{% trans "Account SignUp"
<input type="password"
id="id_password"
name="password1"
value="{{ form.password1.value|default:'' }}"
class="px-4 py-2 w-[100%] h-[28px] transition duration-300 border border-gray-300 rounded focus:border-transparent focus:outline-none focus:ring-4 focus:ring-red-200" />
<span class="help-block">{{ form.password1.errors }}</span>
</div>
Expand All @@ -60,6 +63,7 @@ <h3 class="my-4 text-2xl font-semibold text-gray-700">{% trans "Account SignUp"
<input type="password"
id="id_password2"
name="password2"
value="{{ form.password2.value|default:'' }}"
class="px-4 py-2 w-[100%] h-[28px] transition duration-300 border border-gray-300 rounded focus:border-transparent focus:outline-none focus:ring-4 focus:ring-red-200" />
<span class="help-block">{{ form.password2.errors }}</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion website/templates/feature_suggestion.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ <h2 id="semiheading">Suggest us Features</h2>
<textarea id="description"
name="description"
rows="4"
placeholder="Description of your suggestion (optional)"></textarea>
placeholder="Description of your suggestion"></textarea>
<br>
<button type="submit" onclick="Savefeature()">Post Suggestion</button>
</form>
Expand Down
101 changes: 57 additions & 44 deletions website/templates/users.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load gravatar %}
{% load static %}
{% block style %}
<style type="text/tailwindcss">
@layer components {
Expand All @@ -20,71 +21,83 @@
{% include "includes/sidenav.html" %}
<div class="container py-8 min-h-[100vh]">
<div class="flex flex-col text-center gap-4 mb-10 p-4">
<div class="w-[full] h-max flex flex-col items-center">
<p class="text-7xl mb-5 font-bold">Meet our Community</p>
<div class="w-full h-max flex flex-col items-center">
<p class="text-7xl mb-5 font-bold">Explore Our Community Members</p>
<p class="text-xl bg-red-600 text-white w-max px-5 py-2 rounded-lg lg:text-4xl">
A warm and welcoming collection of open sourcers
</p>
</div>
<div class="font=['Ubuntu'] max-sm:w-full w-3/4">
</div>
<div class="font-['Ubuntu'] max-sm:w-full w-3/4 mx-auto">
<select class="w-full p-3 border rounded-2xl bg-gray-100 text-lg font-semibold"
onchange="window.location.href = `{% url 'users' %}?tag=${this.value}`">
{% for tag_info in user_related_tags %}
<button class="mr-3"
onclick="window.location.href=`{% url 'users' %}?tag={{ tag_info.name }}`">
<div class="{% if tag_info.name == tag %}bg-red-600{% else %}[#f4f4f4]{% endif %} rounded-2xl p-3 m-2">
{{ tag_info.name }}
</div>
</button>
<option value="{{ tag_info.name }}"
{% if forloop.first and not tag %}selected{% elif tag_info.name == tag %}selected{% endif %}>
{{ tag_info.name }}
</option>
{% endfor %}
</div>
</select>
</div>
<div class="flex items-center justify-center flex-wrap gap-4 p-4">
{% for user in users %}
<div class="group card w-[250px] h-[400px] m-5 flex flex-col items-center justify-between hover:bg-red-600 transition duration-200">
{% if user.userprofile.avatar %}
<img src="{{ user.avatar }}"
<div class="group card w-[250px] h-[400px] m-5 flex flex-col items-center justify-between border rounded-lg transition duration-200 shadow-lg hover:shadow-2xl">
{% if user.user_avatar %}
<img src="{{ user.user_avatar.url }}"
class="w-[100px] h-[100px] mb-3 rounded-full object-cover transition duration-200 group-hover:scale-110"
width="100px"
height="100px"
alt="user image" />
{% else %}
<img src="{% gravatar_url user.email 100 %}"
<img src="{% static 'images/dummy-user.png' %}"
class="w-[100px] h-[100px] mb-3 rounded-full object-cover transition duration-200 group-hover:scale-110"
width="100px"
height="100px"
alt="user image" />
{% endif %}
<div class="transition duration-200 group-hover:text-white text-gray-900 text-4xl font-bold">
{{ user.user.username }}
<div class="transition duration-200 group-hover:text-red-500 text-gray-900 text-4xl font-bold">
<a href="{% url 'profile' slug=user.user.username %}"
class="profile-link transition duration-200 hover:text-red-500">{{ user.user.username }}</a>
</div>
<div class="transition duration-200 group-hover:text-purple-800 text-purple-600 text-2xl">{{ user.location }}</div>
<p class="transition duration-200 group-hover:text-white text-gray-600 text-center px-10">
{{ user.role|slice:":30" }}
</p>
<p class="transition duration-200 group-hover:text-white text-gray-600 text-center px-10 py-4 bg-gray-100 rounded-md shadow-md">
<span class="font-semibold text-lg">Discounted Hourly Rate:</span>
<div class="text-purple-600 text-2xl">{{ user.role }}</div>
<p class="transition duration-200 text-gray-600 text-center px-10 py-4 bg-gray-100 rounded-md shadow-md">
<span class="font-semibold text-lg text-gray-600">Discounted Hourly Rate:</span>
<span class="text-green-600 font-bold text-xl">${{ user.discounted_hourly_rate }}</span>
</p>
<div class="group-hover:text-white flex items-center justify-center gap-3 mt-2 w-auto h-5 text-gray-600 mt-7">
<a href="{{ user.x_username }}"
target="_blank"
rel="noopener noreferrer">
<i class="group-hover:text-white scale-150 m-3 fa-brands fa-x-twitter fa-lg cursor-pointer transition duration-200 hover:text-gray-400"></i>
</a>
<a href="{{ user.linkedin_url }}"
target="_blank"
rel="noopener noreferrer">
<i class="group-hover:text-white scale-150 m-3 fa-brands fa-linkedin fa-lg cursor-pointer transition duration-200 hover:text-gray-400"></i>
</a>
<a href="{{ user.website_url }}"
target="_blank"
rel="noopener noreferrer">
<i class="group-hover:text-white scale-150 m-3 fa-brands fa-dribbble fa-lg cursor-pointer transition duration-200 hover:text-gray-400"></i>
</a>
<a href="{{ user.github_url }}"
target="_blank"
rel="noopener noreferrer">
<i class="group-hover:text-white scale-150 m-3 fa-brands fa-github fa-lg cursor-pointer transition duration-200 hover:text-gray-400"></i>
</a>
<div class="flex items-center justify-center gap-3 mt-2 w-auto h-5 text-gray-600 mt-7">
{% if user.x_username %}
<a href="{{ user.x_username }}"
target="_blank"
rel="noopener noreferrer">
<i class="fa-brands fa-x-twitter fa-lg cursor-pointer transition duration-200 hover:text-red-500 scale-125 m-3"></i>
</a>
{% endif %}
{% if user.linkedin_url %}
<a href="{{ user.linkedin_url }}"
target="_blank"
rel="noopener noreferrer">
<i class="fa-brands fa-linkedin fa-lg cursor-pointer transition duration-200 hover:text-red-500 scale-125 m-3"></i>
</a>
{% endif %}
{% if user.github_url %}
<a href="{{ user.github_url }}"
target="_blank"
rel="noopener noreferrer">
<i class="fa-brands fa-github fa-lg cursor-pointer transition duration-200 hover:text-red-500 scale-125 m-3"></i>
</a>
{% endif %}
{% if user.website_url %}
<a href="{{ user.website_url }}"
target="_blank"
rel="noopener noreferrer">
<i class="fa-brands fa-dribbble fa-lg cursor-pointer transition duration-200 hover:text-red-500 scale-125 m-3"></i>
</a>
{% endif %}
</div>
<a href="{% url 'profile' slug=user.user.username %}"
class="w-[150px] h-[40px] rounded-md shadow-md bg-red-500 text-white flex justify-center items-center mt-10 no-underline hover:text-white group-hover:bg-white group-hover:text-red-500 font-bold">More Info</a>
class="w-[150px] h-[40px] rounded-md shadow-md bg-white text-red-500 flex justify-center items-center mt-10 no-underline hover:bg-red-500 hover:text-white font-bold transition duration-200 text-[15px]">
More Info
</a>
</div>
{% endfor %}
</div>
Expand Down
5 changes: 1 addition & 4 deletions website/views/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import os
import urllib
import uuid
from datetime import datetime, timezone

import requests
Expand Down Expand Up @@ -384,10 +383,8 @@ def add_suggestions(request):
data = json.loads(request.body)
title = data.get("title")
description = data.get("description", "")
id = str(uuid.uuid4())
print(description, title, id)
if title and description and user:
suggestion = Suggestion(user=user, title=title, description=description, id=id)
suggestion = Suggestion(user=user, title=title, description=description)
suggestion.save()
messages.success(request, "Suggestion added successfully.")
return JsonResponse({"status": "success"})
Expand Down
9 changes: 8 additions & 1 deletion website/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,14 @@ def create_issue(self, form):
save=True,
)
obj.user_agent = self.request.META.get("HTTP_USER_AGENT")

if len(self.request.FILES.getlist("screenshots"))==0:
messages.error(self.request, "Screenshot is needed!")
obj.delete()
return render(
self.request,
"report.html",
{"form": self.get_form(), "captcha_form": captcha_form},
)
if len(self.request.FILES.getlist("screenshots")) > 5:
messages.error(self.request, "Max limit of 5 images!")
obj.delete()
Expand Down
4 changes: 2 additions & 2 deletions website/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ def users_view(request, *args, **kwargs):
else:
context["users"] = UserProfile.objects.none() # No users if the tag isn't found
else:
context["tag"] = "BLT Contributors"
context["users"] = UserProfile.objects.filter(tags__name="BLT Contributors")
context["tag"] = "BLT-Contributors"
context["users"] = UserProfile.objects.filter(tags__name="BLT-Contributors")

return render(request, "users.html", context=context)

Expand Down

0 comments on commit 77b0d4a

Please sign in to comment.