From 4af7a491e16affaf67bb5e9f9c8245252a175312 Mon Sep 17 00:00:00 2001 From: Anirudh Prabhakaran Date: Sun, 18 Aug 2024 00:18:11 +0530 Subject: [PATCH 1/6] Add a primitive profile page --- ...e_pic_alter_executivemember_date_joined.py | 24 +++++++++++ corpus/accounts/models.py | 1 + corpus/accounts/urls.py | 2 + corpus/accounts/views.py | 12 ++++++ corpus/templates/accounts/profile.html | 43 +++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 corpus/accounts/migrations/0007_user_profile_pic_alter_executivemember_date_joined.py create mode 100644 corpus/templates/accounts/profile.html diff --git a/corpus/accounts/migrations/0007_user_profile_pic_alter_executivemember_date_joined.py b/corpus/accounts/migrations/0007_user_profile_pic_alter_executivemember_date_joined.py new file mode 100644 index 00000000..39ece926 --- /dev/null +++ b/corpus/accounts/migrations/0007_user_profile_pic_alter_executivemember_date_joined.py @@ -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'), + ), + ] diff --git a/corpus/accounts/models.py b/corpus/accounts/models.py index 9c17762e..aad11d16 100644 --- a/corpus/accounts/models.py +++ b/corpus/accounts/models.py @@ -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 = [] diff --git a/corpus/accounts/urls.py b/corpus/accounts/urls.py index 4153603d..2fc0c3ac 100644 --- a/corpus/accounts/urls.py +++ b/corpus/accounts/urls.py @@ -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"), @@ -25,4 +26,5 @@ PasswordResetCompleteView.as_view(), name="password_reset_complete", ), + path("profile/", profile, name="accounts_profile") ] diff --git a/corpus/accounts/views.py b/corpus/accounts/views.py index 3c64f948..59ae74ff 100644 --- a/corpus/accounts/views.py +++ b/corpus/accounts/views.py @@ -6,6 +6,7 @@ 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 @@ -80,3 +81,14 @@ 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 + + args = { + "exec_member": exec_member, + "user": user + } + + return render(request, "accounts/profile.html", args) \ No newline at end of file diff --git a/corpus/templates/accounts/profile.html b/corpus/templates/accounts/profile.html new file mode 100644 index 00000000..b02cdb89 --- /dev/null +++ b/corpus/templates/accounts/profile.html @@ -0,0 +1,43 @@ +{% extends 'base.html' %} + +{% block title %} + {{ user }} | Profile +{% endblock %} + +{% block content %} +
+
+
+
+ {% if user.profile_pic %} + {{ user }} + {% else %} + {{ user }} + {% endif %} +
+
+
+

{{ user }}

+
{{ exec_member.sig }}
+
+
+
+
Date Joined
+
{{ exec_member.date_joined.date }}
+ +
Minor Branch
+
{{ exec_member.minor_branch }}
+ +
IEEE Membership Number
+
{{ exec_member.ieee_number }}
+ +
IEEE Email ID
+
{{ exec_member.ieee_email }}
+ +
Is NEP Member?
+
{{ exec_member.is_nep|yesno:"Yes,No" }}
+ +
+
+{% endblock %} \ No newline at end of file From 77b5360817402939158d140f83c8e2d679deaa42 Mon Sep 17 00:00:00 2001 From: Anirudh Prabhakaran Date: Wed, 21 Aug 2024 23:34:14 +0530 Subject: [PATCH 2/6] Add profile link in navbar --- corpus/templates/components/navbar_profile_dropdown.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/corpus/templates/components/navbar_profile_dropdown.html b/corpus/templates/components/navbar_profile_dropdown.html index ccf30a5a..af164492 100644 --- a/corpus/templates/components/navbar_profile_dropdown.html +++ b/corpus/templates/components/navbar_profile_dropdown.html @@ -3,7 +3,8 @@
  • Welcome, {{ user.first_name }} {{ user.last_name }}!
  • -
  • Profile
  • -
  • Settings
  • + {% if user.executivemember %} +
  • Profile
  • + {% endif %}
  • Logout
  • From 13862ed1a2d94dd464c415e4be0bc7da251505d8 Mon Sep 17 00:00:00 2001 From: Anirudh Prabhakaran Date: Thu, 22 Aug 2024 09:08:23 +0530 Subject: [PATCH 3/6] Update profile page and add virtual expo reports --- corpus/accounts/views.py | 8 +- corpus/templates/accounts/profile.html | 117 +++++++++++++++++++------ 2 files changed, 96 insertions(+), 29 deletions(-) diff --git a/corpus/accounts/views.py b/corpus/accounts/views.py index 59ae74ff..da37b9ab 100644 --- a/corpus/accounts/views.py +++ b/corpus/accounts/views.py @@ -11,6 +11,7 @@ from .forms import CorpusCreationForm from .forms import CorpusLoginForm from .models import ExecutiveMember +from virtual_expo.models import Report, ReportMember # Create your views here. @@ -86,9 +87,14 @@ 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 + "user": user, + "reports": reports } return render(request, "accounts/profile.html", args) \ No newline at end of file diff --git a/corpus/templates/accounts/profile.html b/corpus/templates/accounts/profile.html index b02cdb89..6c5b96ae 100644 --- a/corpus/templates/accounts/profile.html +++ b/corpus/templates/accounts/profile.html @@ -5,39 +5,100 @@ {% endblock %} {% block content %} -
    -
    -
    -
    - {% if user.profile_pic %} - {{ user }} +
    + +
    + {% if user.profile_pic %} + {{ user }} + {% else %} + {{ user }} + {% endif %} + +

    {{ user }}

    + +

    {{ exec_member.sig }}

    +
    + + +
    +
    +
    Personal Information
    +
    +
    +
    Name
    +
    {{ user }}
    +
    Date Joined
    +
    {{ exec_member.date_joined.date }}
    +
    +
    +
    +
    +
    IEEE Membership Information
    +
    +
    +
    IEEE Membership Number
    +
    {{ exec_member.ieee_number }}
    +
    IEEE Membership Email
    +
    {{ exec_member.ieee_email }}
    +
    +
    +
    +
    +
    Reports Published
    +
    + {% if reports %} +
    + +
    {% else %} - {{ user }} + No reports available yet. Check back soon! {% endif %}
    -
    -

    {{ user }}

    -
    {{ exec_member.sig }}
    +
    +
    Blogs Published
    +
    + + Coming Soon! +
    +
    +
    +
    Links
    +
    +
    +
    GitHub
    +
    + {% if exec_member.github %} + {{ exec_member.github }} + {% else %} + None + {% endif %} +
    +
    LinkedIn
    +
    + {% if exec_member.linedin %} + {{ exec_member.linkedin }} + {% else %} + None + {% endif %} +
    +
    +
    -
    -
    Date Joined
    -
    {{ exec_member.date_joined.date }}
    - -
    Minor Branch
    -
    {{ exec_member.minor_branch }}
    - -
    IEEE Membership Number
    -
    {{ exec_member.ieee_number }}
    - -
    IEEE Email ID
    -
    {{ exec_member.ieee_email }}
    - -
    Is NEP Member?
    -
    {{ exec_member.is_nep|yesno:"Yes,No" }}
    - -
    {% endblock %} \ No newline at end of file From 8ff29248e8aaee3972d00ebd62da997a75d194e7 Mon Sep 17 00:00:00 2001 From: CodePokeX Date: Thu, 26 Dec 2024 18:05:15 +0530 Subject: [PATCH 4/6] Blogs page linked to profile page --- ...e_pic_alter_executivemember_date_joined.py | 24 ------------------- .../migrations/0008_user_profile_pic.py | 18 ++++++++++++++ corpus/accounts/views.py | 6 ++++- corpus/templates/accounts/profile.html | 22 +++++++++++++---- 4 files changed, 40 insertions(+), 30 deletions(-) delete mode 100644 corpus/accounts/migrations/0007_user_profile_pic_alter_executivemember_date_joined.py create mode 100644 corpus/accounts/migrations/0008_user_profile_pic.py diff --git a/corpus/accounts/migrations/0007_user_profile_pic_alter_executivemember_date_joined.py b/corpus/accounts/migrations/0007_user_profile_pic_alter_executivemember_date_joined.py deleted file mode 100644 index 39ece926..00000000 --- a/corpus/accounts/migrations/0007_user_profile_pic_alter_executivemember_date_joined.py +++ /dev/null @@ -1,24 +0,0 @@ -# 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'), - ), - ] diff --git a/corpus/accounts/migrations/0008_user_profile_pic.py b/corpus/accounts/migrations/0008_user_profile_pic.py new file mode 100644 index 00000000..47d9ca10 --- /dev/null +++ b/corpus/accounts/migrations/0008_user_profile_pic.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.3 on 2024-12-25 12:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0007_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'), + ), + ] diff --git a/corpus/accounts/views.py b/corpus/accounts/views.py index da37b9ab..b83ab59b 100644 --- a/corpus/accounts/views.py +++ b/corpus/accounts/views.py @@ -12,6 +12,7 @@ from .forms import CorpusLoginForm from .models import ExecutiveMember from virtual_expo.models import Report, ReportMember +from blog.models import Post # Create your views here. @@ -90,11 +91,14 @@ def profile(request, roll_no): # Get Virtual Expo Reports reports = Report.objects.filter(reportmember__member=exec_member) + # Get Blogs written by the Executive Member + blogs = Post.objects.filter(author=exec_member) args = { "exec_member": exec_member, "user": user, - "reports": reports + "reports": reports, + "blogs": blogs, } return render(request, "accounts/profile.html", args) \ No newline at end of file diff --git a/corpus/templates/accounts/profile.html b/corpus/templates/accounts/profile.html index 6c5b96ae..5dd43fbb 100644 --- a/corpus/templates/accounts/profile.html +++ b/corpus/templates/accounts/profile.html @@ -70,10 +70,22 @@

    {{ exec_member.sig }}

    Blogs Published
    - - Coming Soon! + {% if blogs %} +
    +
      + {% for blog in blogs %} +
    • +

      {{ blog.title }}

      +

      {{ blog.description }}

      +

      Published on: {{ blog.published_date|date:"M d, Y" }}

      + Read More +
    • + {% endfor %} +
    +
    + {% else %} + No blogs available yet. Check back soon! + {% endif %}
    @@ -83,7 +95,7 @@

    {{ exec_member.sig }}

    GitHub
    {% if exec_member.github %} - {{ exec_member.github }} + Read More {% else %} None {% endif %} From f8a1bde162f71fbf4f25a4b33bea24aec8247ceb Mon Sep 17 00:00:00 2001 From: CodePokeX Date: Wed, 8 Jan 2025 21:52:31 +0530 Subject: [PATCH 5/6] Edit Profile Page added --- corpus/accounts/forms.py | 32 +++ ...09_executivemember_hide_github_and_more.py | 23 ++ corpus/accounts/models.py | 7 +- corpus/accounts/urls.py | 4 +- corpus/accounts/validators.py | 7 + corpus/accounts/views.py | 59 ++++- corpus/templates/accounts/edit_profile.html | 210 ++++++++++++++++++ corpus/templates/accounts/profile.html | 35 ++- 8 files changed, 367 insertions(+), 10 deletions(-) create mode 100644 corpus/accounts/migrations/0009_executivemember_hide_github_and_more.py create mode 100644 corpus/templates/accounts/edit_profile.html diff --git a/corpus/accounts/forms.py b/corpus/accounts/forms.py index 3f89abf0..c9d05e7f 100644 --- a/corpus/accounts/forms.py +++ b/corpus/accounts/forms.py @@ -4,6 +4,7 @@ from django.contrib.auth.forms import UserCreationForm from .models import User +from .models import ExecutiveMember class CorpusCreationForm(UserCreationForm): @@ -61,3 +62,34 @@ def clean_username(self): if username: username = username.lower() return username + +class UserForm(forms.ModelForm): + class Meta: + model = User + fields = ['phone_no', 'gender', 'email', 'profile_pic'] + widgets = { + 'phone_no': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), + 'gender': forms.Select(attrs={'class': 'rounded-lg border-gray-300 text-black'}), + 'email': forms.EmailInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), + 'profile_pic': forms.ClearableFileInput(attrs={'multiple': False}), + + } + +class ExecutiveMemberForm(forms.ModelForm): + class Meta: + model = ExecutiveMember + fields = [ + 'edu_email', 'roll_number', 'reg_number', 'minor_branch', + 'ieee_number', 'ieee_email', 'linkedin', 'github', 'is_nep' + ] + widgets = { + 'edu_email': forms.EmailInput(attrs={'class': 'rounded-lg border-gray-300 text-black', 'required': True}), + 'roll_number': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black', 'required': True}), + 'reg_number': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black', 'required': True}), + 'minor_branch': forms.Select(attrs={'class': 'rounded-lg border-gray-300 text-black'}), + 'ieee_number': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black','required': True}), + 'ieee_email': forms.EmailInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), + 'linkedin': forms.URLInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), + 'github': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), + 'is_nep': forms.CheckboxInput(), + } \ No newline at end of file diff --git a/corpus/accounts/migrations/0009_executivemember_hide_github_and_more.py b/corpus/accounts/migrations/0009_executivemember_hide_github_and_more.py new file mode 100644 index 00000000..28be173f --- /dev/null +++ b/corpus/accounts/migrations/0009_executivemember_hide_github_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.1.3 on 2025-01-07 13:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0008_user_profile_pic'), + ] + + operations = [ + migrations.AddField( + model_name='executivemember', + name='hide_github', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='executivemember', + name='hide_linkedin', + field=models.BooleanField(default=False), + ), + ] diff --git a/corpus/accounts/models.py b/corpus/accounts/models.py index 16dbe50a..16ace65b 100644 --- a/corpus/accounts/models.py +++ b/corpus/accounts/models.py @@ -11,6 +11,7 @@ from .validators import validate_phone_number from .validators import validate_reg_number from .validators import validate_roll_number +from .validators import validate_image class UserManager(BaseUserManager): @@ -56,7 +57,9 @@ 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) + profile_pic = models.ImageField(upload_to="accounts/profile/pics", + validators=[validate_image], + blank=True, null=True, default=None) USERNAME_FIELD = "email" REQUIRED_FIELDS = [] @@ -139,6 +142,8 @@ class ExecutiveMember(models.Model): github = models.CharField( max_length=39, blank=True, null=True, verbose_name="GitHub Username" ) + hide_github = models.BooleanField(default=False) + hide_linkedin = models.BooleanField(default=False) is_nep = models.BooleanField(default=False, verbose_name="Is NEP Member?") date_joined = models.DateTimeField( default=timezone.localtime, verbose_name="Date Joined" diff --git a/corpus/accounts/urls.py b/corpus/accounts/urls.py index 42cb287d..5c2b87fd 100644 --- a/corpus/accounts/urls.py +++ b/corpus/accounts/urls.py @@ -8,6 +8,7 @@ from .views import signout from .views import signup from .views import profile +from .views import edit_profile urlpatterns = [ path("signup/", signup, name="accounts_signup"), @@ -31,5 +32,6 @@ PasswordResetCompleteView.as_view(), name="password_reset_complete", ), - path("profile/", profile, name="accounts_profile") + path("profile/", profile, name="accounts_profile"), + path("profile/edit/", edit_profile, name="edit_profile") ] diff --git a/corpus/accounts/validators.py b/corpus/accounts/validators.py index c322a7c8..de3ddc22 100644 --- a/corpus/accounts/validators.py +++ b/corpus/accounts/validators.py @@ -47,3 +47,10 @@ def validate_ieee_email(value): if not value.endswith("@ieee.org"): raise ValidationError("Email must end with @ieee.org") email_validator(value) + +def validate_image(image): + file_size = image.file.size + limit = 5 * 1024 * 1024 # 5 MB limit + if file_size > limit: + raise ValidationError("Image size exceeds 5MB.") + diff --git a/corpus/accounts/views.py b/corpus/accounts/views.py index b83ab59b..6cee9a1f 100644 --- a/corpus/accounts/views.py +++ b/corpus/accounts/views.py @@ -4,16 +4,21 @@ from django.contrib.auth import authenticate from django.contrib.auth import login from django.contrib.auth import logout +from django.contrib.auth.decorators import login_required 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 .forms import UserForm +from .forms import ExecutiveMemberForm from .models import ExecutiveMember +# from .models import User from virtual_expo.models import Report, ReportMember from blog.models import Post + # Create your views here. @@ -101,4 +106,56 @@ def profile(request, roll_no): "blogs": blogs, } - return render(request, "accounts/profile.html", args) \ No newline at end of file + return render(request, "accounts/profile.html", args) + +@login_required +def edit_profile(request, roll_no): + user = request.user # Get the currently logged-in user + + # Check if the user has an associated ExecutiveMember record + try: + executive_member = ExecutiveMember.objects.get(roll_number=roll_no, user=user) + except ExecutiveMember.DoesNotExist: + executive_member = None # Handle the case where the user is not an ExecutiveMember + + if request.method == 'POST': + user_form = UserForm(request.POST, request.FILES, instance=user) + if executive_member: + executive_member_form = ExecutiveMemberForm(request.POST, instance=executive_member) + else: + executive_member_form = ExecutiveMemberForm(request.POST) + + if user_form.is_valid() and executive_member_form.is_valid(): + user_form.save() + # Handle hiding GitHub/LinkedIn if checkboxes are selected + hide_linkedin = request.POST.get('hide_linkedin', False) + hide_github = request.POST.get('hide_github', False) + + if hide_linkedin: + executive_member.hide_linkedin = True + else: + executive_member.hide_linkedin = False + + if hide_github: + executive_member.hide_github = True + else: + executive_member.hide_github = False + executive_member_form.save() + return redirect('accounts_profile', roll_no=roll_no) + + else: + user_form = UserForm(instance=user) + if executive_member: + executive_member_form = ExecutiveMemberForm(instance=executive_member) + else: + executive_member_form = ExecutiveMemberForm() + + return render( + request, + 'accounts/edit_profile.html', + { + 'user_form': user_form, + 'executive_member_form': executive_member_form, + 'exec_member': executive_member, + } + ) \ No newline at end of file diff --git a/corpus/templates/accounts/edit_profile.html b/corpus/templates/accounts/edit_profile.html new file mode 100644 index 00000000..6a71b16f --- /dev/null +++ b/corpus/templates/accounts/edit_profile.html @@ -0,0 +1,210 @@ +{% extends 'base.html' %} + +{% block title %} + Edit Profile | {{ user }} +{% endblock %} + +{% block content %} +
    +

    Edit Profile

    + +
    + {% csrf_token %} + + +
    +
    +

    Personal Information

    +
    + + +
    + + + +
    + {% if user.profile_pic %} + {{ user }} + {% else %} + {{ user }} + {% endif %} +
    + + + + + +
    + + +
    + {% for field in user_form %} +
    + + {{ field }} + {% if field.errors %} +
    + {% for error in field.errors %} + {{ error }} + {% endfor %} +
    + {% endif %} + {% if field.help_text %} + + {% endif %} +
    + {% endfor %} +
    + +
    +
    +
    + + {% if executive_member_form %} + +
    +
    +

    NITK Details

    +
    +
    + + {{ executive_member_form.edu_email }} +
    +
    + + {{ executive_member_form.roll_number }} +
    +
    + + {{ executive_member_form.reg_number }} +
    +
    + + {{ executive_member_form.minor_branch }} +
    +
    +
    +
    + + +
    +
    +

    IEEE Details

    +
    +
    + + {{ executive_member_form.ieee_number }} +
    +
    + + {{ executive_member_form.ieee_email }} +
    +
    +
    +
    + + +
    +
    +

    Socials

    +
    + +
    + + {{ executive_member_form.linkedin }} + +
    + + +
    + + {{ executive_member_form.github }} + +
    +
    +
    +
    + {% endif %} + + +
    + + + Go Back + +
    +
    +
    + + + +{% endblock %} diff --git a/corpus/templates/accounts/profile.html b/corpus/templates/accounts/profile.html index 5dd43fbb..1f02e8db 100644 --- a/corpus/templates/accounts/profile.html +++ b/corpus/templates/accounts/profile.html @@ -20,6 +20,13 @@

    {{ user }}

    Core Post comes here

    -->

    {{ exec_member.sig }}

    + + +
    @@ -31,7 +38,7 @@

    {{ exec_member.sig }}

    Name
    {{ user }}
    Date Joined
    -
    {{ exec_member.date_joined.date }}
    +
    {{ exec_member.date_joined|date:"M d, Y" }}
    @@ -92,25 +99,39 @@

    {{ blog.title }}

    Links
    +
    GitHub
    - {% if exec_member.github %} - Read More + {% if exec_member.hide_github %} + -- {% else %} - None + {% if exec_member.github %} + GitHub Profile + {% else %} + None + {% endif %} {% endif %}
    + +
    LinkedIn
    - {% if exec_member.linedin %} - {{ exec_member.linkedin }} + {% if exec_member.hide_linkedin %} + -- {% else %} - None + {% if exec_member.linkedin %} + LinkedIn Profile + {% else %} + None + {% endif %} {% endif %}
    +
    + + {% endblock %} \ No newline at end of file From 771e35f61a5ee80d5a8e7ed4c0538ed9beefce13 Mon Sep 17 00:00:00 2001 From: CodePokeX Date: Fri, 10 Jan 2025 20:57:39 +0530 Subject: [PATCH 6/6] Profile Page and Edit Profile Page modified --- corpus/accounts/forms.py | 22 +++--- corpus/templates/accounts/edit_profile.html | 87 +++++++++++++++++---- corpus/templates/accounts/profile.html | 70 +++++++++-------- 3 files changed, 119 insertions(+), 60 deletions(-) diff --git a/corpus/accounts/forms.py b/corpus/accounts/forms.py index c9d05e7f..2ec1c4d9 100644 --- a/corpus/accounts/forms.py +++ b/corpus/accounts/forms.py @@ -68,9 +68,9 @@ class Meta: model = User fields = ['phone_no', 'gender', 'email', 'profile_pic'] widgets = { - 'phone_no': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), - 'gender': forms.Select(attrs={'class': 'rounded-lg border-gray-300 text-black'}), - 'email': forms.EmailInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), + 'phone_no': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 bg-base-200'}), + 'gender': forms.Select(attrs={'class': 'rounded-lg border-gray-300 bg-base-200'}), + 'email': forms.EmailInput(attrs={'class': 'rounded-lg border-gray-300 bg-base-200'}), 'profile_pic': forms.ClearableFileInput(attrs={'multiple': False}), } @@ -83,13 +83,13 @@ class Meta: 'ieee_number', 'ieee_email', 'linkedin', 'github', 'is_nep' ] widgets = { - 'edu_email': forms.EmailInput(attrs={'class': 'rounded-lg border-gray-300 text-black', 'required': True}), - 'roll_number': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black', 'required': True}), - 'reg_number': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black', 'required': True}), - 'minor_branch': forms.Select(attrs={'class': 'rounded-lg border-gray-300 text-black'}), - 'ieee_number': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black','required': True}), - 'ieee_email': forms.EmailInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), - 'linkedin': forms.URLInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), - 'github': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 text-black'}), + 'edu_email': forms.EmailInput(attrs={'class': 'rounded-lg border-gray-300 bg-base-200', 'required': True}), + 'roll_number': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 bg-base-200', 'required': True}), + 'reg_number': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 bg-base-200', 'required': True}), + 'minor_branch': forms.Select(attrs={'class': 'rounded-lg border-gray-300 bg-base-200 w-full',}), + 'ieee_number': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 bg-base-200','required': True}), + 'ieee_email': forms.EmailInput(attrs={'class': 'rounded-lg border-gray-300 bg-base-200'}), + 'linkedin': forms.URLInput(attrs={'class': 'rounded-lg border-gray-300 bg-base-200'}), + 'github': forms.TextInput(attrs={'class': 'rounded-lg border-gray-300 bg-base-200'}), 'is_nep': forms.CheckboxInput(), } \ No newline at end of file diff --git a/corpus/templates/accounts/edit_profile.html b/corpus/templates/accounts/edit_profile.html index 6a71b16f..415f3711 100644 --- a/corpus/templates/accounts/edit_profile.html +++ b/corpus/templates/accounts/edit_profile.html @@ -12,7 +12,7 @@

    Edit Profile

    {% csrf_token %} -
    +

    Personal Information

    @@ -27,10 +27,10 @@

    Personal Information

    {% if user.profile_pic %} {{ user }} + alt="{{ user }}" style="width: 12em;" class="rounded-full h-48 object-cover mx-auto max-w-full shadow-lg" id="profilePicPreview"> {% else %} {{ user }} + alt="{{ user }}" style="width: 12em;" class="rounded-full h-48 object-cover mx-auto max-w-full shadow-lg" id="profilePicPreview"> {% endif %}
    @@ -70,7 +70,7 @@

    Personal Information

    {% if executive_member_form %} -
    +

    NITK Details

    @@ -103,7 +103,7 @@

    NITK Details

    -
    +

    IEEE Details

    @@ -124,7 +124,7 @@

    IEEE Details

    -
    +

    Socials

    @@ -159,18 +159,41 @@

    Socials

    {% endif %} - + + + + + + + + -
    - - - Go Back - +
    + +
    - -
    + + +
    + {% endblock %} diff --git a/corpus/templates/accounts/profile.html b/corpus/templates/accounts/profile.html index 1f02e8db..7eaeadc9 100644 --- a/corpus/templates/accounts/profile.html +++ b/corpus/templates/accounts/profile.html @@ -7,18 +7,15 @@ {% block content %}
    -
    +
    {% if user.profile_pic %} - {{ user }} + {{ user }} {% else %} {{ user }} + alt="{{ user }}" style="width: 12em;" class="rounded-full h-48 object-cover mx-auto max-w-full"/> {% endif %}

    {{ user }}

    -

    {{ exec_member.sig }}

    @@ -30,35 +27,41 @@

    {{ exec_member.sig }}

    -
    -
    +
    +
    Personal Information
    Name
    {{ user }}
    +
    +
    Date Joined
    {{ exec_member.date_joined|date:"M d, Y" }}
    -
    + +
    IEEE Membership Information
    IEEE Membership Number
    {{ exec_member.ieee_number }}
    +
    +
    IEEE Membership Email
    {{ exec_member.ieee_email }}
    -
    + +
    Reports Published
    {% if reports %}
    -
    -
    + +
    Blogs Published
    {% if blogs %} - - {% else %} - No blogs available yet. Check back soon! - {% endif %} +
    +
      + {% for blog in blogs %} +
    • +

      {{ blog.title }}

      +

      {{ blog.description }}

      +

      Published on: {{ blog.published_date|date:"M d, Y" }}

      + Read More +
    • + {% endfor %} +
    +
    + {% else %} + No blogs available yet. Check back soon! + {% endif %}
    -
    + +
    Links
    @@ -112,7 +117,9 @@

    {{ blog.title }}

    {% endif %} {% endif %}
    +
    +
    LinkedIn
    @@ -126,12 +133,9 @@

    {{ blog.title }}

    {% endif %} {% endif %}
    -
    - +
    - - -{% endblock %} \ No newline at end of file +{% endblock %}