diff --git a/AlumniConnect/forms.py b/AlumniConnect/forms.py index e387c6ad..6aa98542 100644 --- a/AlumniConnect/forms.py +++ b/AlumniConnect/forms.py @@ -2,10 +2,72 @@ from django import forms from applications.alumniprofile.models import Profile, Constants, Batch from django.contrib.auth.models import User +from django.contrib.auth.forms import UserCreationForm +from django.core.exceptions import ValidationError from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, Submit, Row, Column, Div, Field from crispy_forms.bootstrap import InlineRadios +import re +# --------------------------------REGISTRATION FORMS FOR STUDENTS AND ALUMNI START-------------------------------------------------------- +class ProfileNewRegister(forms.ModelForm): + + country = forms.ChoiceField(widget=forms.Select( + attrs={'id': 'countryId', 'class': 'countries order-alpha presel-IN custom-select', 'name': 'country'})) + state = forms.ChoiceField( + widget=forms.Select(attrs={'id': 'stateId', 'class': 'states order-alpha custom-select', 'name': 'state'})) + city = forms.ChoiceField( + widget=forms.Select(attrs={'id': 'cityId', 'class': 'cities order-alpha custom-select', 'name': 'city'})) + + checkbox_update = forms.BooleanField(required=True) + + def clean(self): + super(ProfileNewRegister, self).clean() # if necessary + del self._errors['country'] + del self._errors['city'] + del self._errors['state'] + return self.cleaned_data + + class Meta: + model = Profile + + fields = [ + 'city', + 'country', + 'state', + 'year_of_admission', + 'mobile1', + 'mobile2', + 'facebook', + 'instagram', + 'name', + 'fathers_name', + 'spouse_name', + 'sex', + 'alternate_email', + 'date_of_birth', + 'date_of_joining', + 'working_status', + 'branch', + 'programme', + 'batch', + 'current_address', + 'permanent_address', + 'current_position', + 'current_organisation', + 'past_experience', + 'current_course', + 'current_university', + 'linkedin', + 'website', + 'profile_picture', + 'checkbox_update'] + + widgets = { + 'working_status': forms.RadioSelect(choices=Constants.WORKING_STATUS), + } + +# --------------------------------REGISTRATION FORMS FOR STUDENTS AND ALUMNI END-------------------------------------------------------- class RegisterForm(forms.ModelForm): def __init__(self, *args, **kwargs): @@ -16,7 +78,7 @@ def __init__(self, *args, **kwargs): Column('batch', css_class='form-group col-md-4 mb-0'), Column('programme', css_class='form-group col-md-4 mb-0'), Column('branch', css_class='form-group col-md-4 mb-0'), - css_class='form-row' + css_class='form-row my-3' ), Submit('submit', 'Search', css_class=''), ) @@ -66,7 +128,7 @@ class ProfileEdit(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['fathers_name'].label = "Father/Mother's Name" - self.fields['husbands_name'].label = "Husband's Name" + self.fields['spouse_name'].label = "Husband's Name" self.fields['mobile1'].label = "Mobile No." self.fields['mobile2'].label = "Alternate Mobile No." self.fields['batch'].label = 'Year of Passing' @@ -82,48 +144,48 @@ def __init__(self, *args, **kwargs): Field('roll_no', css_class="form-control", wrapper_class='col-md-4'), Field('name', css_class="form-control", wrapper_class='col-md-4'), Field('sex', css_class="custom-select", wrapper_class="col-md-4"), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('fathers_name', css_class="form-control", wrapper_class='col-md-6'), - Field('husbands_name', css_class="form-control", wrapper_class='col-md-6'), - css_class='form-row', + Field('spouse_name', css_class="form-control", wrapper_class='col-md-6'), + css_class='form-row my-3', ), Div( Field('date_of_birth', css_class="form-control", wrapper_class='col-md-4'), Field('year_of_admission', css_class="custom-select", wrapper_class='col-md-4'), Field('batch', css_class="custom-select", wrapper_class="col-md-4"), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('branch', css_class="custom-select", wrapper_class="col-md-6"), Field('programme', css_class="custom-select", wrapper_class="col-md-6"), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('mobile1', css_class="form-control", wrapper_class='col-md-4'), Field('mobile2', css_class="form-control", wrapper_class='col-md-4'), Field('phone_no', css_class="form-control", wrapper_class="col-md-4"), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('email', css_class="form-control", wrapper_class='col-md-6'), Field('alternate_email', css_class="form-control", wrapper_class='col-md-6'), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('current_address', css_class="form-control", wrapper_class='col-md'), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('country', wrapper_class="col-md-4"), Field('state', wrapper_class="col-md-4"), Field('city', wrapper_class="col-md-4"), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('permanent_address', css_class="form-control", wrapper_class='col-md'), - css_class='form-row', + css_class='form-row my-3', ), InlineRadios('working_status'), Div( @@ -131,22 +193,22 @@ def __init__(self, *args, **kwargs): Field('current_organisation', css_class="form-control", wrapper_class='col-md-6 col-lg-4'), Field('date_of_joining', css_class="form-control", wrapper_class='col-md-6 col-lg-4'), Field('past_experience', css_class="form-control", wrapper_class="col-md-6 col-lg-4"), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('current_course', css_class="form-control", wrapper_class='col-md-6 col-lg-4'), Field('current_university', css_class="form-control", wrapper_class='col-md-6 col-lg-4'), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('linkedin', css_class="form-control", wrapper_class='col-md-6'), Field('website', css_class="form-control", wrapper_class='col-md-6'), - css_class='form-row', + css_class='form-row my-3', ), Div( Field('facebook', css_class="form-control", wrapper_class='col-md-6'), Field('instagram', css_class="form-control", wrapper_class='col-md-6'), - css_class='form-row', + css_class='form-row my-3', ), Field('profile_picture', css_class="w-100"), # 'profile_picture', @@ -176,7 +238,7 @@ class Meta: 'instagram', 'name', 'fathers_name', - 'husbands_name', + 'spouse_name', 'sex', 'email', 'roll_no', @@ -210,188 +272,36 @@ class Meta: } -class NewRegister(forms.ModelForm): - date_of_birth = forms.DateField( - widget=forms.TextInput( - attrs={'type': 'date'} - ), - ) - date_of_joining = forms.DateField( - widget=forms.TextInput( - attrs={'type': 'date'} - ), - required=False, - ) - current_address = forms.CharField( - widget=forms.Textarea( - attrs={'rows': 3, 'placeholder': 'Enter Address'} - ), - max_length=4000, - ) - permanent_address = forms.CharField( - widget=forms.Textarea( - attrs={'rows': 3, 'placeholder': 'Enter Permanent Address', } - ), - max_length=4000, - required=False, - ) - country = forms.ChoiceField(widget=forms.Select( - attrs={'id': 'countryId', 'class': 'countries order-alpha presel-IN custom-select', 'name': 'country'})) - state = forms.ChoiceField( - widget=forms.Select(attrs={'id': 'stateId', 'class': 'states order-alpha custom-select', 'name': 'state'})) - city = forms.ChoiceField( - widget=forms.Select(attrs={'id': 'cityId', 'class': 'cities order-alpha custom-select', 'name': 'city'})) - linkedin = forms.URLField(widget=forms.TextInput(attrs={'placeholder': 'Linkedin URL'})) - website = forms.URLField(widget=forms.TextInput(attrs={'placeholder': 'Website'}), required=False) - facebook = forms.URLField(widget=forms.TextInput(attrs={'placeholder': 'Facebook URL'}), required=False) - # checkbox_terms = forms.BooleanField(required=True) - instagram = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Instagram Username'}), required=False) - checkbox_update = forms.BooleanField(required=True) - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.fields['fathers_name'].label = "Father/Mother's Name" - self.fields['husbands_name'].label = "Husband's Name" - self.fields['mobile1'].label = "Mobile No." - self.fields['mobile2'].label = "Alternate Mobile No." - self.fields['batch'].label = 'Year of Passing' - self.fields['sex'].label = 'Gender' - self.fields['phone_no'].label = 'Phone No.' - self.fields['roll_no'].label = 'Roll No.' - self.fields['date_of_birth'].label = 'Date of Birth' - self.fields['year_of_admission'].label = 'Year of Admission' - self.fields['alternate_email'].label = 'Alternate Email' - # self.fields['checkbox_terms'].label = 'I abide by the Terms and Conditions of the Alumni Cell' - self.fields[ - 'checkbox_update'].label = 'I will update my information at regular intervals and will engage in the Alumni network actively.' - self.helper = FormHelper() - self.helper.layout = Layout( - Div( - Field('roll_no', css_class="form-control", wrapper_class='col-md-4'), - Field('name', css_class="form-control", wrapper_class='col-md-4'), - Field('sex', css_class="custom-select", wrapper_class="col-md-4"), - css_class='form-row', - ), - Div( - Field('fathers_name', css_class="form-control", wrapper_class='col-md-6'), - Field('husbands_name', css_class="form-control", wrapper_class='col-md-6'), - css_class='form-row', - ), - Div( - Field('date_of_birth', css_class="form-control", wrapper_class='col-md-4'), - Field('year_of_admission', css_class="custom-select", wrapper_class='col-md-4'), - Field('batch', css_class="custom-select", wrapper_class="col-md-4"), - css_class='form-row', - ), - Div( - Field('branch', css_class="custom-select", wrapper_class="col-md-6"), - Field('programme', css_class="custom-select", wrapper_class="col-md-6"), - css_class='form-row', - ), - Div( - Field('mobile1', css_class="form-control", wrapper_class='col-md-4'), - Field('mobile2', css_class="form-control", wrapper_class='col-md-4'), - Field('phone_no', css_class="form-control", wrapper_class="col-md-4"), - css_class='form-row', - ), - Div( - Field('email', css_class="form-control", wrapper_class='col-md-6'), - Field('alternate_email', css_class="form-control", wrapper_class='col-md-6'), - css_class='form-row', - ), - Div( - Field('current_address', css_class="form-control", wrapper_class='col-md'), - css_class='form-row', - ), - Div( - Field('country', wrapper_class="col-md-4"), - Field('state', wrapper_class="col-md-4"), - Field('city', wrapper_class="col-md-4"), - css_class='form-row', - ), - Div( - Field('permanent_address', css_class="form-control", wrapper_class='col-md'), - css_class='form-row', - ), - InlineRadios('working_status'), - Div( - Field('current_position', css_class="form-control", wrapper_class='col-md-6 col-lg-4'), - Field('current_organisation', css_class="form-control", wrapper_class='col-md-6 col-lg-4'), - Field('date_of_joining', css_class="form-control", wrapper_class='col-md-6 col-lg-4'), - Field('past_experience', css_class="form-control", wrapper_class="col-md-6 col-lg-4"), - css_class='form-row', - ), - Div( - Field('current_course', css_class="form-control", wrapper_class='col-md-6 col-lg-4'), - Field('current_university', css_class="form-control", wrapper_class='col-md-6 col-lg-4'), - css_class='form-row', - ), - Div( - Field('linkedin', css_class="form-control", wrapper_class='col-md-6'), - Field('website', css_class="form-control", wrapper_class='col-md-6'), - css_class='form-row', - ), - Div( - Field('facebook', css_class="form-control", wrapper_class='col-md-6'), - Field('instagram', css_class="form-control", wrapper_class='col-md-6'), - css_class='form-row', - ), - Field('profile_picture', css_class="w-100"), - # 'profile_picture', - 'checkbox_update', - Submit('submit', 'Register'), - ) - - def clean(self): - super(NewRegister, self).clean() # if necessary - del self._errors['country'] - del self._errors['city'] - del self._errors['state'] - return self.cleaned_data +class SignUp(UserCreationForm): + + user_role = forms.ChoiceField(choices=(('A', 'Alumni'), ('S', 'Student'))) - class Meta: - model = Profile + def clean_email(self): + email = self.cleaned_data['email'].lower() + r = User.objects.filter(email=email) + if r: + raise ValidationError('Account with this email id already exists.') + if re.findall("iiitdmj.ac.in$", email): + raise ValidationError( + "Institute email id is not accepted.Kindly enter your personal email id.") + return email - fields = [ - 'city', - 'country', - 'state', - 'year_of_admission', - 'alternate_email', - 'phone_no', - 'mobile1', - 'mobile2', - 'facebook', - 'instagram', - 'name', - 'fathers_name', - 'husbands_name', - 'sex', - 'email', - 'roll_no', - 'date_of_birth', - 'date_of_joining', - 'working_status', - 'branch', - 'programme', - 'batch', - 'current_address', - 'permanent_address', - 'phone_no', - 'current_position', - 'current_organisation', - 'past_experience', - 'current_course', - 'current_university', - 'linkedin', - 'website', - 'profile_picture'] + def clean_username(self): + username = self.cleaned_data.get('username').lower() + r = User.objects.filter(username=username) - widgets = { - 'working_status': forms.RadioSelect(choices=Constants.WORKING_STATUS), - } + # New regex matching for institute id (also added in signup.html) + match = re.search('20(([A-Za-z]{3,5})|(\d{2}))\d{2,5}', username) + if(match == None): + raise ValidationError( + 'Please enter your institute roll number.' + ) + return username + class Meta: + model = User + fields = ['username', 'email', 'password1', 'password2', 'user_role'] class PasswordResetRequestForm(forms.Form): roll_no = forms.IntegerField(label=("Roll No.")) email = forms.CharField(label=("Email"), max_length=254) diff --git a/AlumniConnect/urls.py b/AlumniConnect/urls.py index 75d37304..c9d0bd7e 100644 --- a/AlumniConnect/urls.py +++ b/AlumniConnect/urls.py @@ -1,5 +1,4 @@ """AlumniConnect URL Configuration - The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: @@ -37,13 +36,16 @@ #path('account/reset_password/', views.ResetPasswordRequestView.as_view(), name="reset_password"), path('logout/', LogoutView.as_view(), name='logout'), path('register/', views.register, name='register'), - path('newregister/', views.new_register, name='new_register'), + path('profilecompletion/',views.profile_completion, name='profile_completion'), + # path('newregister/', views.new_register, name='new_register'), + path('signup/', views.signup, name='signup'), re_path(r'^activate/(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', views.activate, name='activate'), path('confirm/', TemplateView.as_view(template_name='AlumniConnect/confirm_email.html'), name = 'confirm'), + path('confirmprofile/', TemplateView.as_view(template_name='AlumniConnect/confirm_profile.html'), name = 'confirmprofile'), path('success/', TemplateView.as_view(template_name='AlumniConnect/account_success.html'), name = 'success'), re_path('^', include('django.contrib.auth.urls')), path('password/', views.change_password, name='change_password'), - re_path(r'^profileedit/(?P[0-9]+)/$', views.profileedit, name='profileedit'), + re_path(r'^profileedit/(?P[0-9A-Za-z]+)/$', views.profileedit, name='profileedit'), path('profile/', include('applications.alumniprofile.urls')), path('members/', include('applications.members.urls')), path('events/', include('applications.events_news.urls')), @@ -72,4 +74,4 @@ admin.site.site_header = "IIITDMJ Alumni Association" admin.site.site_title = "Alumni Association" -admin.site.index_title = "Alumni Association Admin" +admin.site.index_title = "Alumni Association Admin" \ No newline at end of file diff --git a/AlumniConnect/views.py b/AlumniConnect/views.py index b27d74fb..c9ab4e61 100644 --- a/AlumniConnect/views.py +++ b/AlumniConnect/views.py @@ -14,17 +14,24 @@ from django.db.models import Count from django.contrib.auth.views import LoginView from django.contrib.messages.views import SuccessMessageMixin - -from .forms import RegisterForm, ProfileEdit, NewRegister +from django.conf import settings +from django.template.loader import render_to_string +from django.urls import reverse +from django.utils.encoding import force_bytes +from django.utils.html import strip_tags +from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode +from .forms import RegisterForm, ProfileEdit, ProfileNewRegister, SignUp from .token import account_activation_token from applications.events_news.models import Event, Attendees -from applications.alumniprofile.models import Profile, Constants +from applications.alumniprofile.models import Batch, Profile, Constants from applications.news.models import News from applications.gallery.models import Album from applications.geolocation.views import addPoints import datetime from django.utils import timezone from itertools import chain +from django.contrib.sites.shortcuts import get_current_site +from django.core.mail import send_mail # Create your views here. @@ -49,7 +56,8 @@ def index(request): news = News.objects.filter().order_by('-date') # messages.success(request, 'Your password was successfully updated!') events_to_display = list(chain(events, events_completed))[:3] - albums_list = Album.objects.order_by('-created').annotate(images_count=Count('albumimage'))[:3] + albums_list = Album.objects.order_by( + '-created').annotate(images_count=Count('albumimage'))[:3] return render(request, "AlumniConnect/index.html", {'name': sname, 'events': events_to_display, 'news': news, 'albums': albums_list}) @@ -84,7 +92,8 @@ def register(request): batch = form.cleaned_data.get('batch') branch = form.cleaned_data.get('branch') programme = form.cleaned_data.get('programme') - l = Profile.objects.filter(batch=batch, programme=programme, branch=branch) + l = Profile.objects.filter( + batch=batch, programme=programme, branch=branch) print('Testing output\n') print(l) check = True @@ -95,9 +104,12 @@ def register(request): def reg_no_gen(degree_, spec_, year): - degree = {"B.Tech": "1", "B.Des": '2', "M.Tech": '3', "M.Des": '4', "PhD": '5'} - spec = {"NA": '00', "CSE": "01", "ECE": "02", "ME": "03", "MT": "04", "NS": "05", "DS": "06"} - last_reg_no = Profile.objects.filter(year_of_admission=year).order_by('user__date_joined').last() + degree = {"B.Tech": "1", "B.Des": '2', + "M.Tech": '3', "M.Des": '4', "PhD": '5'} + spec = {"NA": '00', "CSE": "01", "ECE": "02", + "ME": "03", "MT": "04", "NS": "05", "DS": "06", "SM": "07"} # Added SM Branch + last_reg_no = Profile.objects.filter( + year_of_admission=year).order_by('user__date_joined').last() # print(last_reg_no) new_reg_no = (int(str(last_reg_no.reg_no)[-4:]) + 1) if last_reg_no else 1 return degree[degree_] + spec[spec_] + str(year)[2:] + str(convert_int(new_reg_no, 4)) @@ -107,41 +119,50 @@ def convert_int(number, decimals): return str(number).zfill(decimals) -def new_register(request): +def signup(request): if request.method == 'POST': - form = NewRegister(request.POST, request.FILES) - # print (request.POST) + form = SignUp(request.POST) if form.is_valid(): - try: - first_name, last_name = request.POST['name'].split(' ', 1) - except: - first_name = request.POST['name'] - last_name = "" - # print (form.cleaned_data.get('date_of_joining')) - profile = form.save(commit=False) - profile.reg_no = reg_no_gen(profile.programme, profile.branch, profile.year_of_admission) - profile.country = request.POST['country'] - profile.state = request.POST['state'] - profile.city = request.POST['city'] - password = User.objects.make_random_password(length=10) - # password = '12345678' - user = User.objects.create_user( - username=str(form.cleaned_data.get('roll_no')), - first_name=first_name, - last_name=last_name, - email=str(form.cleaned_data.get('email')), - password=password, - is_active=True + + # CREATING THE USER FROM THE MODEL FORM DATA + user = form.save() + user.is_active = False + user.save() + # THEN CREATING THE PROFILE INSTANCE AND SAVING THE USER AND user_role + profile = Profile.objects.create( + roll_no=form.cleaned_data.get('username'), + email=form.cleaned_data.get('email'), + user_role=form.cleaned_data.get('user_role'), + batch = Batch(2009), + user=user, ) - profile.user = user profile.save() - mappt = addPoints({'city': str(request.POST['city']), 'state': str(request.POST['state']), - 'country': str(request.POST['country'])}) - print('Adding Map Point Status: ' + str(mappt)) + + # Send Account Activation Email + current_site = get_current_site(request) + from_email = settings.DEFAULT_FROM_EMAIL + to = [user.email] + subject = '[noreply] SAC Account Activation' + html_message = render_to_string('AlumniConnect/acc_active_email.html', { + 'user': user, + 'domain': current_site.domain, + 'uid': urlsafe_base64_encode(force_bytes(user.pk)), + 'token': account_activation_token.make_token(user), + }) + plain_message = strip_tags(html_message) + send_mail( + subject, plain_message, from_email, to, + fail_silently=False, html_message=html_message, + ) + messages.success( + request, f'Your account has been created! Complete your profile to log in') return render(request, 'AlumniConnect/confirm_email.html') + + return render(request, 'AlumniConnect/signup.html', {'form': form}) + # return HttpResponseRedirect('/') else: - form = NewRegister() - return render(request, 'AlumniConnect/profileedit.html', {'form': form, 'edit': False}) + form = SignUp() + return render(request, 'AlumniConnect/signup.html',{'form':form}) @login_required @@ -163,21 +184,63 @@ def profileedit(request, id): return HttpResponseRedirect('/') +@login_required +def profile_completion(request): + profile = Profile.objects.get(roll_no=request.user.username) + if profile.name: + return HttpResponseRedirect('/') + if request.method == 'POST': + + form = ProfileNewRegister( + request.POST, request.FILES, instance=profile) + + # print (request.POST) + if form.is_valid(): + try: + first_name, last_name = request.POST['name'].split(' ', 1) + except: + first_name = request.POST['name'] + last_name = "" + # print (form.cleaned_data.get('date_of_joining')) + profile = form.save(commit=False) + profile.reg_no = reg_no_gen( + profile.programme, profile.branch, profile.year_of_admission) + profile.country = request.POST['country'] + profile.state = request.POST['state'] + profile.city = request.POST['city'] + profile.batch = Batch(request.POST['batch']) + request.user.first_name = first_name + request.user.last_name = last_name + request.user.is_active = False + request.user.save() + profile.save() + + mappt = addPoints({'city': str(request.POST['city']), 'state': str(request.POST['state']), + 'country': str(request.POST['country'])}) + print('Adding Map Point Status: ' + str(mappt)) + return HttpResponseRedirect('/confirmprofile/') + else: + form = ProfileNewRegister() + + batches = list(Batch.objects.all().order_by('batch')) + context = {'form': form, 'edit': False, 'programmes': Constants.PROG_CHOICES, 'user_role': profile.user_role,'branches': Constants.BRANCH, 'batch_year': batches, 'year_of_admission': Constants.YEAR_OF_ADDMISSION} + return render(request, 'AlumniConnect/profileedit.html', context) + def activate(request, uidb64, token): print('inside activate') try: uid = urlsafe_base64_decode(uidb64) print(uid) - u = User.objects.get(username=uid) + u = User.objects.get(pk=uid) print(u) except(TypeError, ValueError, OverflowError): u = None - if u is not None and account_activation_token.check_token(u, token): + if u is not None and account_activation_token.check_token(u, token) and not u.first_name: u.is_active = True u.save() login(request, u) # return HttpResponse('Thank you for your email confirmation. Now you can login your account.') - return HttpResponseRedirect('/password/') + return HttpResponseRedirect('/profilecompletion/') else: return HttpResponse('Activation link is invalid!') return redirect('/') @@ -190,10 +253,11 @@ def change_password(request): if form.is_valid(): user = form.save() update_session_auth_hash(request, user) # Important! - messages.success(request, 'Your password was successfully updated!') + messages.success( + request, 'Your password was successfully updated!') return redirect('home') else: messages.error(request, 'Please correct the error below.') else: form = PasswordChangeForm(request.user) - return render(request, 'AlumniConnect/change_password.html', {'form': form}) + return render(request, 'AlumniConnect/change_password.html', {'form': form}) \ No newline at end of file diff --git a/applications/adminportal/views.py b/applications/adminportal/views.py index 3cba41e6..04273006 100644 --- a/applications/adminportal/views.py +++ b/applications/adminportal/views.py @@ -128,12 +128,13 @@ def registrations_index(request): send_verification_email(request, profile) profile.mail_sent = True profile.verify = True + profile.user.is_active = True messages.add_message(request, messages.SUCCESS, "Registration Success, Mail sent to {}".format(profile.name)) elif 'decline' in request.POST: profile.verify = False messages.add_message(request, messages.SUCCESS, "Registration Declined for {}".format(profile.name)) - + profile.user.save() profile.save() except Exception: print(Exception) diff --git a/applications/alumniprofile/models.py b/applications/alumniprofile/models.py index c599a1bd..dd4840ac 100644 --- a/applications/alumniprofile/models.py +++ b/applications/alumniprofile/models.py @@ -10,6 +10,10 @@ class Constants: + USER_ROLE = ( + ('S','Student'), + ('A','Alumni') + ) SEX_CHOICES = ( ('M', 'Male'), ('F', 'Female'), @@ -28,6 +32,7 @@ class Constants: ('CSE', 'Computer Science and Engineering'), ('ECE', 'Electronics and Communication Engineering'), ('ME', 'Mechanical Engineering'), + ('SM', 'Smart Manufacturing'), ('NS', 'Natural Sciences'), ('MT', 'Mechatronics'), ('DS', 'Design'), @@ -37,15 +42,15 @@ class Constants: WORKING_STATUS = ( ('Is Working', 'Is Working'), ('Is Pursuing Higher Studies', 'Is Pursuing Higher Studies'), - ('Is Self Employed', 'Is Self Employed') + ('Is Self Employed', 'Is Self Employed'), + ('Student', 'Student') ) YEAR_OF_ADDMISSION = tuple((n, str(n)) for n in range(2005, datetime.datetime.now().year)) + - -class Batch(models.Model): +class Batch(models.Model): batch = models.IntegerField(primary_key=True) - def __str__(self): return str(self.batch) @@ -57,16 +62,16 @@ def upload_photo(instance, filename): class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) - roll_no = models.IntegerField(primary_key=True) - email = models.EmailField(null=False, default="") - alternate_email = models.EmailField(null=True, blank=True) + roll_no = models.CharField(primary_key=True,max_length=15) + email = models.EmailField(unique=True,default="") + alternate_email = models.EmailField(null=True,blank=True) year_of_admission = models.IntegerField(null=True, choices=Constants.YEAR_OF_ADDMISSION) batch = models.ForeignKey(Batch, on_delete=models.CASCADE) - name = models.CharField(max_length=1000, default="", null=False) + name = models.CharField(max_length=1000, default="", null=True) fathers_name = models.CharField(max_length=1000, default="") - husbands_name = models.CharField(null=True, blank=True, max_length=1000, default="") - programme = models.CharField(max_length=1000, choices=Constants.PROG_CHOICES, null=False) - branch = models.CharField(choices=Constants.BRANCH, max_length=1000, null=False) + spouse_name = models.CharField(null=True, blank=True, max_length=1000, default="") + programme = models.CharField(max_length=1000, choices=Constants.PROG_CHOICES) + branch = models.CharField(choices=Constants.BRANCH, max_length=1000) sex = models.CharField(max_length=2, choices=Constants.SEX_CHOICES, default='M') date_of_birth = models.DateField(default=datetime.date(1970, 1, 1)) current_address = models.TextField(max_length=1000, default="") @@ -74,7 +79,7 @@ class Profile(models.Model): mobile1 = models.BigIntegerField(null=True) mobile2 = models.BigIntegerField(null=True, blank=True) phone_no = models.BigIntegerField(null=True, blank=True) - working_status = models.CharField(max_length=1000, choices=Constants.WORKING_STATUS, default='1', null=False) + working_status = models.CharField(max_length=1000, blank=True,choices=Constants.WORKING_STATUS, default='1') current_position = models.CharField(max_length=1000, null=True, blank=True) current_organisation = models.CharField(max_length=1000, null=True, blank=True) past_experience = models.IntegerField(null=True, blank=True) @@ -94,7 +99,7 @@ class Profile(models.Model): mail_sent = models.BooleanField(default=False) verify = models.BooleanField(null=True) mail_sent_tracker = FieldTracker(fields=['verify']) - + user_role = models.CharField(max_length=2, choices=Constants.USER_ROLE, default='A') def __str__(self): return self.name diff --git a/applications/alumniprofile/urls.py b/applications/alumniprofile/urls.py index d8fe4352..7f102ace 100644 --- a/applications/alumniprofile/urls.py +++ b/applications/alumniprofile/urls.py @@ -5,5 +5,5 @@ app_name = 'profile' urlpatterns = [ - re_path(r'^(?P[0-9]{6,8})/$', views.profile, name='profile'), + re_path(r'^(?P[0-9A-Za-z]{6,8})/$', views.profile, name='profile'), ] diff --git a/templates/AlumniConnect/acc_active_email.html b/templates/AlumniConnect/acc_active_email.html index 7c9c104a..703bbd37 100644 --- a/templates/AlumniConnect/acc_active_email.html +++ b/templates/AlumniConnect/acc_active_email.html @@ -1,7 +1,486 @@ -{% autoescape off %} -Hi {{ l.name }}, -Please click on the link to confirm your registration, -http://{{ domain }}{% url 'activate' uidb64=uid token=token %} + + -

Your current default Passwords is your Roll No. It is HIGHLY RECOMMENDED to change it after activating your account.

-{% endautoescape %} \ No newline at end of file + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + +
+ +
+ + + + + + +
+
+ + + + + + +
+
+
+ Thanks for signing up, + {{ user }}! 
+
+
+
+ + + + + + +
+
+
+ Your account has been created. +
+ Your username is: {{user}}. +
+
+ Please click on the below link to complete your profile. +
+
+ Thank + you! 
+
+
+
+ + + + + + +
+
+ + + + + + +
+ + + + + + +
+ Complete Profile +
+
+ + + + + + +
+
+ + + + + + +
+
+
+ We kindly request you to:
+
+
+
+ 1. + Keep your profile up-to-date.
+
+
+
+ 2. + Post relevant job postings on the website so that your juniors may get benefitted.
+ +
+
+
+ + + + + + +
+ + + + + + +
+ Visit website +
+
+ + + + + + +
+
+
+ +
+ +
+ +
+
+
+
+
+ + + + + diff --git a/templates/AlumniConnect/confirm_email.html b/templates/AlumniConnect/confirm_email.html index 2125c87c..f715cacc 100644 --- a/templates/AlumniConnect/confirm_email.html +++ b/templates/AlumniConnect/confirm_email.html @@ -37,10 +37,10 @@

- Thank you for registering to IIITDMJ Alumni Association. You will be receiving an email from Admin after verification. + Thank you for registering to IIITDMJ Alumni Association. You will be receiving an email for verifying your email address.

- Thank you again! + Once verified, you'll be able to go ahead and complete your profile.

diff --git a/templates/AlumniConnect/confirm_profile.html b/templates/AlumniConnect/confirm_profile.html new file mode 100644 index 00000000..3082d76c --- /dev/null +++ b/templates/AlumniConnect/confirm_profile.html @@ -0,0 +1,74 @@ +{% extends 'globals/base.html' %} +{% load crispy_forms_tags %} + +{% load static %} + +{% block title %} +Alumni Connect +{% endblock %} + +{% block body %} +{% include 'globals/navbar.html' %} +
+ +
+
+
+
+

+ +

+
+
+

+ ALUMNI CONNECT +

+
+
+
+
+ +
+
+ +
+ +
+{% include 'globals/footer.html' %} +{% endblock %} + \ No newline at end of file diff --git a/templates/AlumniConnect/login.html b/templates/AlumniConnect/login.html index c55e74d5..c8bf71de 100644 --- a/templates/AlumniConnect/login.html +++ b/templates/AlumniConnect/login.html @@ -34,7 +34,7 @@

diff --git a/templates/alumniprofile/profile_form.html b/templates/alumniprofile/profile_form.html new file mode 100644 index 00000000..ea93c86c --- /dev/null +++ b/templates/alumniprofile/profile_form.html @@ -0,0 +1,284 @@ +
+
+ + +
+ +
+ + +
+
+
+
+ + +
+ +
+ + +
+
+ +
+ +
+ + + + + + + + +
+
+ +
+
+ + +
+ +
+ +
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
+ +
+ + +
+ +
+ +
+ +
+
+
+ +
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + + + + + + + + + + +
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ +
+ +
+
+
+
+
+ + +
+
+
+ +
+
+ + + + +
+ +
+ + +
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/templates/globals/navbar.html b/templates/globals/navbar.html index 7f13339e..b7973ff9 100644 --- a/templates/globals/navbar.html +++ b/templates/globals/navbar.html @@ -79,7 +79,7 @@ Login {% else %} {% endif %}