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

Create profile page #164

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.7 on 2024-08-17 17:14

import datetime
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0006_alter_executivemember_date_joined'),
]

operations = [
migrations.AddField(
model_name='user',
name='profile_pic',
field=models.ImageField(blank=True, default=None, null=True, upload_to='accounts/profile/pics'),
),
migrations.AlterField(
model_name='executivemember',
name='date_joined',
field=models.DateTimeField(default=datetime.datetime(2024, 8, 17, 17, 14, 23, 410838, tzinfo=datetime.timezone.utc), verbose_name='Date Joined'),
),
]
1 change: 1 addition & 0 deletions corpus/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class User(AbstractUser):
)
gender = models.CharField(max_length=1, choices=GENDERS)
email = models.EmailField(unique=True, verbose_name="Personal Email")
profile_pic = models.ImageField(upload_to="accounts/profile/pics", blank=True, null=True, default=None)

USERNAME_FIELD = "email"
REQUIRED_FIELDS = []
Expand Down
2 changes: 2 additions & 0 deletions corpus/accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .views import signin
from .views import signout
from .views import signup
from .views import profile

urlpatterns = [
path("signup/", signup, name="accounts_signup"),
Expand All @@ -25,4 +26,5 @@
PasswordResetCompleteView.as_view(),
name="password_reset_complete",
),
path("profile/<roll_no>", profile, name="accounts_profile")
]
18 changes: 18 additions & 0 deletions corpus/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from django.contrib.auth import logout
from django.shortcuts import redirect
from django.shortcuts import render
from django.shortcuts import get_object_or_404

from .forms import CorpusCreationForm
from .forms import CorpusLoginForm
from .models import ExecutiveMember
from virtual_expo.models import Report, ReportMember

# Create your views here.

Expand Down Expand Up @@ -80,3 +82,19 @@ def signout(request):
logout(request)
messages.success(request, "Successfully signed out.")
return redirect("index")

def profile(request, roll_no):
exec_member = get_object_or_404(ExecutiveMember, roll_number=roll_no)
user = exec_member.user

# Get Virtual Expo Reports
reports = Report.objects.filter(reportmember__member=exec_member)


args = {
"exec_member": exec_member,
"user": user,
"reports": reports
}

return render(request, "accounts/profile.html", args)
104 changes: 104 additions & 0 deletions corpus/templates/accounts/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{% extends 'base.html' %}

{% block title %}
{{ user }} | Profile
{% endblock %}

{% block content %}
<div class="w-5/6 md:w-2/3 my-10 mx-auto flex flex-col md:flex-row gap-8">
<!-- Div with image, name, society and core member position if any -->
<div class="w-full md:w-1/3 prose text-center p-5 border border-neutral rounded-lg md:border-none">
{% if user.profile_pic %}
<img src="{{ user.profile_pic.url }}" alt="{{ user }}" class="rounded rounded-full w-64 h-64 mx-auto"/>
{% else %}
<img src="https://api.dicebear.com/9.x/adventurer-neutral/svg?seed={{ exec_member.roll_number }}"
alt="{{ user }}" class="rounded rounded-full w-64 h-64 mx-auto"/>
{% endif %}

<h1 class="my-2">{{ user }}</h1>
<!-- Todo
<h2 class="my-1">Core Post comes here</h2>
-->
<h3 class="m-0">{{ exec_member.sig }}</h3>
</div>

<!-- Div with other information about the person -->
<div class="w-full md:w-2/3 p-5 border border-neutral rounded-lg flex flex-col gap-2">
<div tabindex="0" class="collapse collapse-arrow border-base-300 bg-base-200 border">
<div class="collapse-title text-xl font-bold">Personal Information</div>
<div class="collapse-content">
<div class="grid grid-cols-2 gap-5">
<div class="font-bold">Name</div>
<div>{{ user }}</div>
<div class="font-bold">Date Joined</div>
<div>{{ exec_member.date_joined.date }}</div>
</div>
</div>
</div>
<div tabindex="0" class="collapse collapse-arrow border-base-300 bg-base-200 border">
<div class="collapse-title text-xl font-bold">IEEE Membership Information</div>
<div class="collapse-content">
<div class="grid grid-cols-2 gap-5">
<div class="font-bold">IEEE Membership Number</div>
<div>{{ exec_member.ieee_number }}</div>
<div class="font-bold">IEEE Membership Email</div>
<div>{{ exec_member.ieee_email }}</div>
</div>
</div>
</div>
<div tabindex="0" class="collapse collapse-arrow border-base-300 bg-base-200 border">
<div class="collapse-title text-xl font-bold">Reports Published</div>
<div class="collapse-content">
{% if reports %}
<div class="grid grid-cols-1 gap-5">
<ul class="list-disc p-5">
{% for report in reports %}
<li>
<a href="{% url 'virtual_expo_report' report_id=report.id %}"
class="link link-primary">
[{{ report.year }}] {{ report.title }}
</a>
</li>
{% endfor %}
</ul>
</div>
{% else %}
No reports available yet. Check back soon!
{% endif %}
</div>
</div>
<div tabindex="0" class="collapse collapse-arrow border-base-300 bg-base-200 border">
<div class="collapse-title text-xl font-bold">Blogs Published</div>
<div class="collapse-content">
<!-- Todo after blogs are implemented
<p>tabindex="0" attribute is necessary to make the div focusable</p>
-->
Coming Soon!
</div>
</div>
<div tabindex="0" class="collapse collapse-arrow border-base-300 bg-base-200 border">
<div class="collapse-title text-xl font-bold">Links</div>
<div class="collapse-content">
<div class="grid grid-cols-2 gap-5">
<div class="font-bold">GitHub</div>
<div>
{% if exec_member.github %}
<a href="https://github.com/{{ exec_member.github }}">{{ exec_member.github }}</a>
{% else %}
None
{% endif %}
</div>
<div class="font-bold">LinkedIn</div>
<div>
{% if exec_member.linedin %}
<a href="{{ exec_member.linkedin }}">{{ exec_member.linkedin }}</a>
{% else %}
None
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
5 changes: 3 additions & 2 deletions corpus/templates/components/navbar_profile_dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<li class="font-bold text-white">
Welcome, {{ user.first_name }} {{ user.last_name }}!
</li>
<li><a>Profile</a></li>
<li><a>Settings</a></li>
{% if user.executivemember %}
<li><a href="{% url 'accounts_profile' roll_no=user.executivemember.roll_number %}">Profile</a></li>
{% endif %}
<li><a href="{% url 'accounts_signout' %}">Logout</a></li>
</ul>
Loading