From a6f7933fe0b0371ca3eecb2b5fdbcb54d1c91052 Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:12:01 -0400 Subject: [PATCH] Update user profile form fields and add new fields for LinkedIn URL, 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. --- blt/urls.py | 2 + website/admin.py | 7 +- website/forms.py | 5 ++ .../migrations/0127_tag_created_tag_slug.py | 25 +++++++ ...profile_discounted_hourly_rate_and_more.py | 37 ++++++++++ website/models.py | 13 ++++ website/templates/includes/sidenav.html | 9 +++ website/templates/leaderboard_global.html | 16 ----- website/templates/profile.html | 33 +++++++-- website/templates/profile_edit.html | 52 +++++++++++++- website/templates/users.html | 69 +++++++++++++++++++ website/views.py | 30 ++++++++ 12 files changed, 272 insertions(+), 26 deletions(-) create mode 100644 website/migrations/0127_tag_created_tag_slug.py create mode 100644 website/migrations/0128_userprofile_discounted_hourly_rate_and_more.py create mode 100644 website/templates/users.html diff --git a/blt/urls.py b/blt/urls.py index a4e77f81b..7ccf6c215 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -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"), diff --git a/website/admin.py b/website/admin.py index cd737bd4b..e0fd0cca0 100644 --- a/website/admin.py +++ b/website/admin.py @@ -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) @@ -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) diff --git a/website/forms.py b/website/forms.py index 11292e51c..0c2d11523 100644 --- a/website/forms.py +++ b/website/forms.py @@ -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(), diff --git a/website/migrations/0127_tag_created_tag_slug.py b/website/migrations/0127_tag_created_tag_slug.py new file mode 100644 index 000000000..0d67dd340 --- /dev/null +++ b/website/migrations/0127_tag_created_tag_slug.py @@ -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, + ), + ] diff --git a/website/migrations/0128_userprofile_discounted_hourly_rate_and_more.py b/website/migrations/0128_userprofile_discounted_hourly_rate_and_more.py new file mode 100644 index 000000000..aad3d4cc2 --- /dev/null +++ b/website/migrations/0128_userprofile_discounted_hourly_rate_and_more.py @@ -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), + ), + ] diff --git a/website/models.py b/website/models.py index 290522796..1dc35e92d 100644 --- a/website/models.py +++ b/website/models.py @@ -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 @@ -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 @@ -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: diff --git a/website/templates/includes/sidenav.html b/website/templates/includes/sidenav.html index 7673d0e21..a047d1d9f 100644 --- a/website/templates/includes/sidenav.html +++ b/website/templates/includes/sidenav.html @@ -69,6 +69,15 @@