Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

feat:send email verification for sign up #1168

Open
wants to merge 2 commits into
base: develop
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
36 changes: 36 additions & 0 deletions vms/administrator/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 2.0 on 2020-12-13 14:10

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('cities_light', '0008_city_timezone'),
('organization', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Administrator',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=30, validators=[django.core.validators.RegexValidator('^[(A-Z)|(a-z)|(\\s)|(\\-)]+$')])),
('last_name', models.CharField(max_length=30, validators=[django.core.validators.RegexValidator('^[(A-Z)|(a-z)|(\\s)|(\\-)]+$')])),
('address', models.CharField(max_length=75, validators=[django.core.validators.RegexValidator('^[(A-Z)|(a-z)|(0-9)|(\\s)|(\\-)|(\\.)|(,)|(\\:)]+$')])),
('phone_number', models.CharField(max_length=20, validators=[django.core.validators.RegexValidator('^\\s*(?:\\+?(\\d{1,3}))?([-. (]*(\\d{3})[-. )]*)?((\\d{3})[-. ]*(\\d{2,4})(?:[-.x ]*(\\d+))?)\\s*$', message='Please enter a valid phone number')])),
('email', models.EmailField(max_length=45, unique=True)),
('city', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.City')),
('country', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.Country')),
('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organization.Organization')),
('state', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.Region')),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
32 changes: 32 additions & 0 deletions vms/event/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 2.0 on 2020-12-13 14:10

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('cities_light', '0008_city_timezone'),
]

operations = [
migrations.CreateModel(
name='Event',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=75, validators=[django.core.validators.RegexValidator("^[(A-Z)|(a-z)|(0-9)|(\\s)|(\\.)|(,)|(\\-)|(!)|(\\')]+$")])),
('description', models.TextField(blank=True)),
('start_date', models.DateField()),
('end_date', models.DateField()),
('address', models.CharField(blank=True, max_length=75, null=True, validators=[django.core.validators.RegexValidator("^[(A-Z)|(a-z)|(0-9)|(\\s)|(\\-)|(\\')|(,)]+$")])),
('venue', models.CharField(blank=True, max_length=30, null=True, validators=[django.core.validators.RegexValidator("^[(A-Z)|(a-z)|(\\s)|(\\-)|(\\')]+$")])),
('city', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.City')),
('country', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.Country')),
('state', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.Region')),
],
),
]
28 changes: 28 additions & 0 deletions vms/job/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.0 on 2020-12-13 14:10

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('event', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Job',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=75, validators=[django.core.validators.RegexValidator("^[(A-Z)|(a-z)|(\\s)|(\\')]+$")])),
('start_date', models.DateField()),
('end_date', models.DateField()),
('description', models.TextField(blank=True, validators=[django.core.validators.RegexValidator("^[(A-Z)|(a-z)|(0-9)|(\\s)|(\\.)|(,)|(\\-)|(!)|(\\')]+$")])),
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='event.Event')),
],
),
]
23 changes: 23 additions & 0 deletions vms/organization/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.0 on 2020-12-13 14:10

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Organization',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=75, unique=True, validators=[django.core.validators.RegexValidator("^[(A-Z)|(a-z)|(0-9)|(\\s)|(\\-)|(:)|(\\')]+$")])),
('approved_status', models.IntegerField(default=1)),
],
),
]
12 changes: 12 additions & 0 deletions vms/registration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from registration.tokens import account_activation_token
from volunteer.forms import VolunteerForm
from volunteer.validation import validate_file
from vms.settings import EMAIL_HOST_USER
from django.core.mail import send_mail


class AdministratorSignupView(TemplateView):
Expand Down Expand Up @@ -73,6 +75,11 @@ def post(self, request):
request.POST, prefix="admin")

if user_form.is_valid() and administrator_form.is_valid():
email = request.POST['admin-email']
subject = 'Account Verification'
message = 'Thank you for confirmation of your account'
recepient = email
send_mail(subject, message, EMAIL_HOST_USER, [recepient], fail_silently=False)
password1 = request.POST.get('usr-password')
password2 = request.POST.get('usr-confirm_password')
if not match_password(password1, password2):
Expand Down Expand Up @@ -205,6 +212,11 @@ def post(self, request):
request.POST, request.FILES, prefix="vol")

if user_form.is_valid() and volunteer_form.is_valid():
email = request.POST['vol-email']
subject = 'Account Verification'
message = 'Thank you for confirmation of your account'
recepient = email
send_mail(subject, message, EMAIL_HOST_USER, [recepient], fail_silently=False)
password1 = request.POST.get('usr-password')
password2 = request.POST.get('usr-confirm_password')
if not match_password(password1, password2):
Expand Down
58 changes: 58 additions & 0 deletions vms/shift/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 2.0 on 2020-12-13 14:10

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='EditRequest',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('start_time', models.TimeField()),
('end_time', models.TimeField()),
],
),
migrations.CreateModel(
name='Report',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('total_hrs', models.DecimalField(decimal_places=2, max_digits=20)),
('confirm_status', models.IntegerField(default=0)),
('date_submitted', models.DateField(default=django.utils.timezone.now)),
],
),
migrations.CreateModel(
name='Shift',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('date', models.DateField()),
('start_time', models.TimeField()),
('end_time', models.TimeField()),
('max_volunteers', models.IntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(5000)])),
('address', models.CharField(blank=True, max_length=75, null=True, validators=[django.core.validators.RegexValidator("^[(A-Z)|(a-z)|(0-9)|(\\s)|(\\-)|(\\')|(,)]+$")])),
('venue', models.CharField(blank=True, max_length=30, null=True, validators=[django.core.validators.RegexValidator("^[(A-Z)|(a-z)|(\\s)|(\\-)|(\\')]+$")])),
],
),
migrations.CreateModel(
name='VolunteerShift',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('start_time', models.TimeField(blank=True, null=True)),
('end_time', models.TimeField(blank=True, null=True)),
('date_logged', models.DateTimeField(blank=True, null=True)),
('edit_requested', models.BooleanField(default=False)),
('report_status', models.BooleanField(choices=[(False, 'Not reported'), (True, 'Reported')], default=False)),
('shift', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shift.Shift')),
],
),
]
64 changes: 64 additions & 0 deletions vms/shift/migrations/0002_auto_20201213_1410.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Generated by Django 2.0 on 2020-12-13 14:10

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('shift', '0001_initial'),
('job', '0001_initial'),
('cities_light', '0008_city_timezone'),
('volunteer', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='volunteershift',
name='volunteer',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='volunteer.Volunteer'),
),
migrations.AddField(
model_name='shift',
name='city',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.City'),
),
migrations.AddField(
model_name='shift',
name='country',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.Country'),
),
migrations.AddField(
model_name='shift',
name='job',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='job.Job'),
),
migrations.AddField(
model_name='shift',
name='state',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.Region'),
),
migrations.AddField(
model_name='shift',
name='volunteers',
field=models.ManyToManyField(through='shift.VolunteerShift', to='volunteer.Volunteer'),
),
migrations.AddField(
model_name='report',
name='volunteer',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='volunteer.Volunteer'),
),
migrations.AddField(
model_name='report',
name='volunteer_shifts',
field=models.ManyToManyField(to='shift.VolunteerShift'),
),
migrations.AddField(
model_name='editrequest',
name='volunteer_shift',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='shift.VolunteerShift'),
),
]
1 change: 1 addition & 0 deletions vms/srv/vms/resume/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
220000000000000
1 change: 1 addition & 0 deletions vms/srv/vms/resume/output_3goGlmr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
220000000000000
17 changes: 13 additions & 4 deletions vms/vms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,19 @@

# Instead of sending out real email, during development the emails will be sent
# to stdout, where from they can be inspected.
if DEBUG:
EMAIL_HOST = config('EMAIL_HOST', default='localhost')
EMAIL_PORT = config('EMAIL_PORT', default=1025, cast=int)
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# if DEBUG:
# EMAIL_HOST = config('EMAIL_HOST', default='localhost')
# EMAIL_PORT = config('EMAIL_PORT', default=1025, cast=int)
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'


# SMTP configuration
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = config('EMAIL')
EMAIL_HOST_PASSWORD = config('EMAIL_PASS')

LOGIN_REDIRECT_URL = reverse_lazy('home:index')
RECOVER_ONLY_ACTIVE_USERS = False
Expand Down
41 changes: 41 additions & 0 deletions vms/volunteer/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated by Django 2.0 on 2020-12-13 14:10

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
('cities_light', '0008_city_timezone'),
('organization', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Volunteer',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=30, validators=[django.core.validators.RegexValidator('^[(A-Z)|(a-z)|(\\s)|(\\-)]+$')])),
('last_name', models.CharField(max_length=30, validators=[django.core.validators.RegexValidator('^[(A-Z)|(a-z)|(\\s)|(\\-)]+$')])),
('address', models.CharField(max_length=75, validators=[django.core.validators.RegexValidator('^[(A-Z)|(a-z)|(0-9)|(\\s)|(\\-)|(\\.)|(,)|(\\:)]+$')])),
('phone_number', models.CharField(max_length=20, validators=[django.core.validators.RegexValidator('^\\s*(?:\\+?(\\d{1,3}))?([-. (]*(\\d{3})[-. )]*)?((\\d{3})[-. ]*(\\d{2,4})(?:[-.x ]*(\\d+))?)\\s*$', message='Please enter a valid phone number')])),
('email', models.EmailField(max_length=45, unique=True)),
('websites', models.TextField(blank=True, validators=[django.core.validators.RegexValidator('^(https?:\\/\\/(?:www\\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|www\\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\\.[^\\s]{2,}|https?:\\/\\/(?:www\\.|(?!www))[a-zA-Z0-9]\\.[^\\s]{2,}|www\\.[a-zA-Z0-9]\\.[^\\s]{2,})+$')])),
('description', models.TextField(blank=True, validators=[django.core.validators.RegexValidator('^[(A-Z)|(a-z)|(0-9)|(\\s)|(\\.)|(,)|(\\-)|(!)]+$')])),
('resume', models.TextField(blank=True, validators=[django.core.validators.RegexValidator('^[(A-Z)|(a-z)|(0-9)|(\\s)|(\\.)|(,)|(\\-)|(!)]+$')])),
('resume_file', models.FileField(blank=True, max_length=75, upload_to='vms/resume/')),
('reminder_days', models.IntegerField(blank=True, default=1, validators=[django.core.validators.MaxValueValidator(50), django.core.validators.MinValueValidator(1)])),
('city', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.City')),
('country', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.Country')),
('organization', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='organization.Organization')),
('state', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cities_light.Region')),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]