Skip to content

Commit

Permalink
Update user profile form fields and add new fields for LinkedIn URL, …
Browse files Browse the repository at this point in the history
…GitHub URL, website URL, discounted hourly rate, and X username. Add users endpoint to URL patterns. Refactor admin page for tags to display additional fields and prepopulate slug field. Add migration files for tag and user profile changes. Remove unused CSS class in sidenav.html and leaderboard_global.html.
  • Loading branch information
DonnieBLT committed Aug 10, 2024
1 parent 7cc834e commit a6f7933
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 26 deletions.
2 changes: 2 additions & 0 deletions blt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@
path("robots.txt", website.views.robots_txt),
path("ads.txt", website.views.ads_txt),
re_path(r"^contributors/$", contributors_view, name="contributors"),
# users
path("users/", website.views.users_view, name="users"),
path("company/", include("company.urls")),
path("sponsor/", website.views.sponsor_view, name="sponsor"),
path("companies/", DomainListView.as_view(), name="domain_lists"),
Expand Down
7 changes: 6 additions & 1 deletion website/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ class ProjectAdmin(admin.ModelAdmin):
search_fields = ["name", "description", "slug"]


class TagAdmin(admin.ModelAdmin):
list_display = ("name", "slug", "created")
prepopulated_fields = {"slug": ("name",)}


# Register all models with their respective admin classes
admin.site.register(Project, ProjectAdmin)
admin.site.register(ContributorStats)
Expand Down Expand Up @@ -346,4 +351,4 @@ class ProjectAdmin(admin.ModelAdmin):
admin.site.register(IP, IPAdmin)
admin.site.register(Transaction)
admin.site.register(Monitor, MonitorAdmin)
admin.site.register(Tag)
admin.site.register(Tag, TagAdmin)
5 changes: 5 additions & 0 deletions website/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class Meta:
"tags",
"subscribed_domains",
"subscribed_users",
"linkedin_url",
"x_username",
"website_url",
"discounted_hourly_rate",
"github_url",
]
widgets = {
"tags": forms.CheckboxSelectMultiple(),
Expand Down
25 changes: 25 additions & 0 deletions website/migrations/0127_tag_created_tag_slug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.0.7 on 2024-08-10 19:41

import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("website", "0126_alter_userprofile_subscribed_domains_and_more"),
]

operations = [
migrations.AddField(
model_name="tag",
name="created",
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name="tag",
name="slug",
field=models.SlugField(default="", unique=True),
preserve_default=False,
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 5.0.7 on 2024-08-10 20:56

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("website", "0127_tag_created_tag_slug"),
]

operations = [
migrations.AddField(
model_name="userprofile",
name="discounted_hourly_rate",
field=models.DecimalField(decimal_places=2, default=0, max_digits=10),
),
migrations.AddField(
model_name="userprofile",
name="github_url",
field=models.URLField(blank=True, null=True),
),
migrations.AddField(
model_name="userprofile",
name="linkedin_url",
field=models.URLField(blank=True, null=True),
),
migrations.AddField(
model_name="userprofile",
name="website_url",
field=models.URLField(blank=True, null=True),
),
migrations.AddField(
model_name="userprofile",
name="x_username",
field=models.CharField(blank=True, max_length=50, null=True),
),
]
13 changes: 13 additions & 0 deletions website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from django.db.models import Count
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from django.template.defaultfilters import slugify
from django.utils import timezone
from google.api_core.exceptions import NotFound
from google.cloud import storage
Expand Down Expand Up @@ -46,6 +47,13 @@ class Subscription(models.Model):

class Tag(models.Model):
name = models.CharField(max_length=255)
slug = models.SlugField(unique=True)
created = models.DateTimeField(auto_now_add=True)

def save(self, *args, **kwargs):
# make the slug using slugify
self.slug = slugify(self.name)
super(Tag, self).save(*args, **kwargs)

def __str__(self):
return self.name
Expand Down Expand Up @@ -517,6 +525,11 @@ class UserProfile(models.Model):
eth_address = models.CharField(max_length=100, blank=True, null=True)
created = models.DateTimeField(auto_now_add=True)
tags = models.ManyToManyField(Tag, blank=True)
x_username = models.CharField(max_length=50, blank=True, null=True)
linkedin_url = models.URLField(blank=True, null=True)
github_url = models.URLField(blank=True, null=True)
website_url = models.URLField(blank=True, null=True)
discounted_hourly_rate = models.DecimalField(max_digits=10, decimal_places=2, default=0)

def avatar(self, size=36):
if self.user_avatar:
Expand Down
9 changes: 9 additions & 0 deletions website/templates/includes/sidenav.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@
</li>
<li class="{% if request.path == '/leaderboard/' %}bg-gray-200{% endif %}">
<a href="{% url 'leaderboard_global' %}"
class="flex items-center w-full text-black no-underline p-2">
<div class="w-8 mr-4">
<i class="fa fa-trophy"></i>
</div>
<span>Leaderboard</span>
</a>
</li>
<li class="{% if request.path == '/users/' %}bg-gray-200{% endif %}">
<a href="{% url 'users' %}"
class="flex items-center w-full text-black no-underline p-2">
<div class="w-8 mr-4">
<i class="fa fa-trophy"></i>
Expand Down
16 changes: 0 additions & 16 deletions website/templates/leaderboard_global.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,6 @@
<h1 class="page-header">Global Leaderboard</h1>
</div>
</div>
{% if user_related_tags %}
<div class="row flex justify-center">
<div class="col-md-8">
<div class="list-group">
<div class="tag-container">
{% for tag in user_related_tags %}
<a href="?tag={{ tag.name }}"
class="tag-pill {% cycle 'tag-primary' 'tag-secondary' 'tag-success' 'tag-danger' 'tag-warning' 'tag-info' %}">
{{ tag.name }}
</a>
{% endfor %}
</div>
</div>
</div>
</div>
{% endif %}
<div class="row flex justify-center">
<div class="col-md-8">
<div class="list-group">
Expand Down
33 changes: 27 additions & 6 deletions website/templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
text-decoration: inherit;
}


.list-group .label-default {
margin-top: 3px;
}
Expand Down Expand Up @@ -82,10 +81,6 @@
width: 200px;
}





.scroll {
max-height: 1100px;
overflow-y: auto;
Expand Down Expand Up @@ -259,6 +254,21 @@
#bch:checked~.s1 {
margin-left: -60%;
}

/* Added styles for description and discounted hourly rate */
.profile-description,
.profile-rate {
max-width: 100%;
word-wrap: break-word;
margin-top: 1rem;
font-size: 14px;
line-height: 1.5;
}

.profile-rate {
color: #ff5722;
font-weight: bold;
}
</style>
{% endblock style %}
{% block content %}
Expand Down Expand Up @@ -317,6 +327,16 @@
{% endif %}
<div class="mt-[2rem] !ml-0">{% include "./includes/crypto_donation.html" %}</div>
<div class="h-[2vh]"></div>
{% if user.userprofile.description %}
<div>Bio / Description</div>
<div class="profile-description">{{ user.userprofile.description }}</div>
<hr>
{% endif %}
{% if user.userprofile.discounted_hourly_rate %}
<div>Discounted Hourly Rate</div>
<div class="profile-rate">{{ user.userprofile.discounted_hourly_rate }}</div>
<hr>
{% endif %}
<div>
<div class="font-bold mb-3 mt-1">
Recent Activity
Expand Down Expand Up @@ -479,7 +499,8 @@
</div>
<div class="font=['Ubuntu'] max-sm:w-full w-3/4">
{% for tag in user_related_tags %}
<button class="mr-3">
<button class="mr-3"
onclick="window.location.href=`{% url 'users' %}?tag={{ tag.name }}`">
<div class="bg-[#f4f4f4] rounded-2xl p-3 m-2">{{ tag.name }}</div>
</button>
{% endfor %}
Expand Down
52 changes: 49 additions & 3 deletions website/templates/profile_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,52 @@ <h2 class="text-3xl font-semibold text-center mb-8">Edit Profile</h2>
rows="4"
class="mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">{{ form.description.value }}</textarea>
</div>
<!-- Discounted Hourly Rate -->
<div class="mb-4">
<label for="id_discounted_hourly_rate"
class="block text-sm font-medium text-gray-700">Discounted Hourly Rate $/hr</label>
<input type="number"
name="discounted_hourly_rate"
id="id_discounted_hourly_rate"
value="{{ form.discounted_hourly_rate.value }}"
class="mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<!-- LinkedIn URL -->
<div class="mb-4">
<label for="id_linkedin_url" class="block text-sm font-medium text-gray-700">LinkedIn URL</label>
<input type="url"
name="linkedin_url"
id="id_linkedin_url"
value="{{ form.linkedin_url.value|default_if_none:"" }}"
class="mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<!-- GitHub URL -->
<div class="mb-4">
<label for="id_github_url" class="block text-sm font-medium text-gray-700">GitHub URL</label>
<input type="url"
name="github_url"
id="id_github_url"
value="{{ form.github_url.value|default_if_none:"" }}"
class="mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<!-- X username -->
<div class="mb-4">
<label for="id_x_username" class="block text-sm font-medium text-gray-700">X Username</label>
<input type="text"
name="x_username"
id="id_x_username"
value="{{ form.x_username.value|default_if_none:"" }}"
class="mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<!-- Website URL -->
<div class="mb-4">
<label for="id_website_url" class="block text-sm font-medium text-gray-700">Website URL</label>
<input type="url"
name="website_url"
id="id_website_url"
value="{{ form.website_url.value|default_if_none:"" }}"
class="mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<!-- Issues Hidden -->
<div class="mb-4">
<label for="id_issues_hidden"
Expand All @@ -54,7 +100,7 @@ <h2 class="text-3xl font-semibold text-center mb-8">Edit Profile</h2>
<input type="text"
name="btc_address"
id="id_btc_address"
value="{{ form.btc_address.value }}"
value="{{ form.btc_address.value|default_if_none:"" }}"
class="mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<!-- BCH Address -->
Expand All @@ -63,7 +109,7 @@ <h2 class="text-3xl font-semibold text-center mb-8">Edit Profile</h2>
<input type="text"
name="bch_address"
id="id_bch_address"
value="{{ form.bch_address.value }}"
value="{{ form.bch_address.value|default_if_none:"" }}"
class="mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<!-- ETH Address -->
Expand All @@ -72,7 +118,7 @@ <h2 class="text-3xl font-semibold text-center mb-8">Edit Profile</h2>
<input type="text"
name="eth_address"
id="id_eth_address"
value="{{ form.eth_address.value }}"
value="{{ form.eth_address.value|default_if_none:"" }}"
class="mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<!-- Tags -->
Expand Down
69 changes: 69 additions & 0 deletions website/templates/users.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{% extends "base.html" %}
{% block style %}
<style type="text/tailwindcss">
@layer components {
.card {
@apply flex items-center justify-center flex-col gap-2 p-5 w-full sm:w-72 h-full bg-gray-100 border rounded-2xl;
}
}
</style>
<!--Tailwind CSS-->
<!--Font-Awesome-->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA=="
crossorigin="anonymous"
referrerpolicy="no-referrer" />
{% endblock style %}
{% block content %}
{% 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>
<div class="font=['Ubuntu'] max-sm:w-full w-3/4">
{% 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>
{% endfor %}
</div>
</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">
<img src="{{ user.img }}"
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" />
<div class="transition duration-200 group-hover:text-white text-gray-900 text-4xl font-bold">
{{ user.user.username }}
</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.short_description }}
</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.twitter }}" 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 }}" 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 }}" 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>
</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>
</div>
{% endfor %}
</div>
</div>
{% endblock content %}
Loading

0 comments on commit a6f7933

Please sign in to comment.