Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Teams Page #134

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9c4098e
Added tab component and styled it appropriately
yukitya-1811 Jan 24, 2024
ccd4530
Basic HTML for Team Page done
yukitya-1811 Jan 26, 2024
e76ad81
Added profile_picture to ExecutiveMember model
yukitya-1811 Jan 26, 2024
3fbe833
Merge branch 'IEEE-NITK:main' into TeamPage
yukitya-1811 Jan 26, 2024
1c52b05
Finalized HTML for Faculty and Member separation on each sig tab
yukitya-1811 Feb 6, 2024
3da4e98
Finished section separation within each sig tab for Faculty, Core and…
yukitya-1811 Feb 8, 2024
a4f0904
Added logic to fetch coremember pfp from execmember
yukitya-1811 Feb 8, 2024
a6c0b67
Fixed light mode colours
yukitya-1811 Feb 19, 2024
880b625
Finished layout for member cards and buttons
yukitya-1811 Feb 24, 2024
9fb8c57
Fixed minor issue (Piston members being loaded in Diode members section)
yukitya-1811 Feb 24, 2024
f856a07
Formatted code for better readability
yukitya-1811 Feb 24, 2024
33c47bd
Fixed centering of tablist issue (Finally)
yukitya-1811 Feb 28, 2024
4cd43dd
Added links to all Github and Linkedin buttons
yukitya-1811 Feb 28, 2024
4de896a
Added proper verbose_name_plural for Faculty
yukitya-1811 Feb 28, 2024
c364ec3
After pre commit hooks
yukitya-1811 Feb 28, 2024
75c2922
Revert "Added links to all Github and Linkedin buttons"
yukitya-1811 Feb 28, 2024
57f503f
Merge branch 'main' into TeamPage
yukitya-1811 Feb 28, 2024
34c08e3
Resolving conflicts #1
yukitya-1811 Feb 28, 2024
9e153fd
Merge branch 'TeamPage' of https://github.com/yukitya-1811/corpus int…
yukitya-1811 Feb 28, 2024
fc8ffe3
Cleaned up migrations
yukitya-1811 Feb 29, 2024
4643f52
Changed upload folder for profile pictures to accounts/executivemember
yukitya-1811 Mar 6, 2024
b04c662
Update corpus/pages/urls.py
yukitya-1811 Mar 6, 2024
7dec563
Add Teampage link to small navbar
yukitya-1811 Mar 12, 2024
0ee74d1
Reverted changes
yukitya-1811 Mar 12, 2024
34e21c0
Add Team link to small navbar
yukitya-1811 Mar 12, 2024
29acc3f
DB fix commit
yukitya-1811 Mar 12, 2024
6ad1640
Made pre-commit changes
yukitya-1811 Mar 13, 2024
c967b3c
Added default pfp png
yukitya-1811 Mar 13, 2024
0fe008b
Made requested changes
yukitya-1811 Mar 13, 2024
0834376
Finished faculty website buttons
yukitya-1811 Mar 13, 2024
61aba1f
Added checks for links belonging to Faculty model
yukitya-1811 Mar 13, 2024
829451d
Fixed conflicts
yukitya-1811 Mar 13, 2024
d514b78
Merge branch 'main' of https://github.com/yukitya-1811/corpus into main
yukitya-1811 Mar 13, 2024
802807e
Merge branch 'TeamPage' into main
yukitya-1811 Mar 13, 2024
f411c87
Revert "Merge branch 'TeamPage' into main"
yukitya-1811 Mar 13, 2024
7ee3770
Merge branch 'IEEE-NITK:main' into main
yukitya-1811 Mar 14, 2024
d767f9a
Merge TeamPage into main
yukitya-1811 Mar 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion corpus/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from .models import ExecutiveMember
from .models import User
from .models import Faculty
from .models import Core

# Register your models here.

Expand Down Expand Up @@ -67,7 +69,7 @@ class ExecutiveMemberAdmin(admin.ModelAdmin):
),
(
"IEEE Related Details",
{"fields": ("ieee_number", "ieee_email")},
{"fields": ("ieee_number", "ieee_email", "profile_picture")},
),
("Socials", {"fields": ("linkedin", "github")}),
)
Expand All @@ -81,6 +83,14 @@ class ExecutiveMemberAdmin(admin.ModelAdmin):
)
ordering = ("user",)

class CoreAdmin(admin.ModelAdmin):
list_display = ("user", "sig", "post", "term_start")

class FacultyAdmin(admin.ModelAdmin):
list_display = ("user", "sig", "post", "term_start")


admin.site.register(User, CorpusUserAdmin)
admin.site.register(ExecutiveMember, ExecutiveMemberAdmin)
admin.site.register(Core, CoreAdmin)
admin.site.register(Faculty, FacultyAdmin)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Generated by Django 4.2.7 on 2024-02-29 12:37
import datetime

import django.db.models.deletion
import django.utils.timezone
from django.conf import settings
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = [
("config", "0004_sig_society_sigs"),
("accounts", "0002_alter_user_email_alter_user_phone_no_executivemember"),
]

operations = [
migrations.AddField(
model_name="executivemember",
name="profile_picture",
field=models.ImageField(
blank=True, null=True, upload_to="execmember/profile_picture"
),
),
migrations.AlterField(
model_name="executivemember",
name="date_joined",
field=models.DateTimeField(
default=datetime.datetime(2024, 2, 29, 18, 7, 3, 350454),
verbose_name="Date Joined",
),
),
migrations.AlterField(
model_name="executivemember",
name="github",
field=models.CharField(
blank=True, max_length=200, null=True, verbose_name="GitHub Username"
),
),
migrations.CreateModel(
name="Faculty",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("post", models.CharField(max_length=100)),
("term_start", models.DateField(default=django.utils.timezone.now)),
("term_end", models.DateField(null=True)),
(
"sig",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="config.sig"
),
),
(
"user",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name_plural": "faculties",
},
),
migrations.CreateModel(
name="Core",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("post", models.CharField(max_length=100)),
("term_start", models.DateField(default=django.utils.timezone.now)),
("term_end", models.DateField(null=True)),
(
"sig",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="config.sig"
),
),
(
"user",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
]

This file was deleted.

25 changes: 24 additions & 1 deletion corpus/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.contrib.auth.base_user import BaseUserManager
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _

from .validators import validate_ieee_email
Expand Down Expand Up @@ -135,13 +136,16 @@ class ExecutiveMember(models.Model):
blank=True, null=True, verbose_name="Linkedin Profile URL"
)

profile_picture = models.ImageField(
blank=True, null=True, upload_to="accounts/executivemember/profile_picture"
)
# TODO: Phase out with GitHub OAuth details
github = models.CharField(
max_length=200, blank=True, null=True, verbose_name="GitHub Username"
)
is_nep = models.BooleanField(default=False, verbose_name="Is NEP Member?")
date_joined = models.DateTimeField(
default=datetime.now(), verbose_name="Date Joined"
verbose_name="Date Joined", default=datetime.now()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the django.utils.timezone.now() function here instead?

)

def save(self, *args, **kwargs):
Expand All @@ -151,3 +155,22 @@ def save(self, *args, **kwargs):

def __str__(self):
return f"{self.user.first_name} {self.user.last_name} [{self.sig.name}]"


class Core(models.Model):
user = models.OneToOneField(User, null=False, on_delete=models.CASCADE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're decoupling Core and Faculty, I think this can be a OneToOne to ExecutiveMember instead. Only Executive Members should have the ability to take core positions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey I tried doing that but now I have this issue when I try to makemigrations

It is impossible to add a non-nullable field 'executivemember' to core without specifying a default. This is because the database needs something to populate existing rows.
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
 2) Quit and manually define a default value in models.py.

I tried deleting all pre-existing model instances from the db and it still throws the error. How can I fix this? It has bugged me a lot in the past too lol.

Further, I cannot open the Core model menu in the django-admin site. It throws this error page at me:

image

Plx help

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the following:

  • Stop all running containers - docker kill $(docker ps -a -q)
  • Delete the DB volume - docker volume rm postgres_data
  • (Optional) Prune your system - docker system prune
  • Restart all containers - docker compose up --build

Note that this will nuke your existing data in the DB. If you've created temp users and other things, maybe try to dump the data using dumpdata

post = models.CharField(max_length=100, null=False)
yukitya-1811 marked this conversation as resolved.
Show resolved Hide resolved
sig = models.ForeignKey(SIG, null=False, on_delete=models.CASCADE)
term_start = models.DateField(default=now, null=False)
yukitya-1811 marked this conversation as resolved.
Show resolved Hide resolved
term_end = models.DateField(null=True)
yukitya-1811 marked this conversation as resolved.
Show resolved Hide resolved


class Faculty(models.Model):
yukitya-1811 marked this conversation as resolved.
Show resolved Hide resolved
class Meta:
verbose_name_plural = "faculties"

user = models.OneToOneField(User, null=False, on_delete=models.CASCADE)
sig = models.ForeignKey(SIG, null=False, on_delete=models.CASCADE)
post = models.CharField(max_length=100, null=False)
yukitya-1811 marked this conversation as resolved.
Show resolved Hide resolved
term_start = models.DateField(default=now, null=False)
yukitya-1811 marked this conversation as resolved.
Show resolved Hide resolved
term_end = models.DateField(null=True)
4 changes: 4 additions & 0 deletions corpus/corpus/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from django.contrib import admin
from django.urls import include
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path("admin/", admin.site.urls),
Expand All @@ -28,3 +30,5 @@
path("skyward_expedition/", include("skyward_expedition.urls")),
path("robotrix/", include("robotrix.urls")),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
1 change: 1 addition & 0 deletions corpus/pages/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
path("", views.index, name="index"),
path("about_us/", views.about_us, name="about_us"),
path("sig/<str:sig_name>/", views.sig, name="sig"),
path("team/", views.team, name="team"),
]
39 changes: 39 additions & 0 deletions corpus/pages/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from accounts.models import Core
from accounts.models import ExecutiveMember
from accounts.models import Faculty
from config.models import SIG
from config.models import Society
from django.db.models import Q
from django.shortcuts import get_object_or_404
from django.shortcuts import render

Expand Down Expand Up @@ -41,3 +45,38 @@ def sig(request, sig_name):
}

return render(request, "pages/sig.html", args)


def team(request):
compsoc_members = ExecutiveMember.objects.filter(
(Q(core__isnull=True) | Q(core=None))
& (Q(user__faculty__isnull=True) | Q(user__faculty=None))
& Q(sig__name="CompSoc")
)
diode_members = ExecutiveMember.objects.filter(
(Q(core__isnull=True) | Q(core=None))
& (Q(user__faculty__isnull=True) | Q(user__faculty=None))
& Q(sig__name="Diode")
)
piston_members = ExecutiveMember.objects.filter(
(Q(core__isnull=True) | Q(core=None))
& (Q(user__faculty__isnull=True) | Q(user__faculty=None))
& Q(sig__name="Piston")
)
ieee_core = Core.objects.filter(sig__name="ExeCom").order_by("post")
compsoc_core = Core.objects.filter(sig__name="CompSoc").order_by("post")
diode_core = Core.objects.filter(sig__name="Diode").order_by("post")
piston_core = Core.objects.filter(sig__name="Piston").order_by("post")

faculty = Faculty.objects.all()
context = {
"compsoc_members": compsoc_members,
"diode_members": diode_members,
"piston_members": piston_members,
"ieee_core": ieee_core,
"compsoc_core": compsoc_core,
"diode_core": diode_core,
"piston_core": piston_core,
"faculty": faculty,
}
return render(request, "pages/team.html", context)
1 change: 1 addition & 0 deletions corpus/templates/components/navbar_large.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<div class="navbar-center">
<a href="{% url 'index' %}" class="btn btn-ghost normal-case text-lg">Home</a>
<a href="{% url 'about_us' %}" class="btn btn-ghost normal-case text-lg">About Us</a>
<a href="{% url 'team'%}" class="btn btn-ghost normal-case text-lg"> Team </a>
<div class="dropdown">
<label tabindex="0" class="btn btn-ghost normal-case text-lg">
SIGs
Expand Down
Loading
Loading