Skip to content
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
6 changes: 2 additions & 4 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def signup(request):
plan = Plan.objects.first()

day = plan.duration_days

ends_time = timezone.now() + timedelta(days=day)

subscription = Subscription.objects.get_or_create(
Expand Down Expand Up @@ -120,7 +120,7 @@ def get(self, request, user_id, token):
message = get_template(
'teams/login_credentials_email.html').render({
'email': f'{user.email}',
'password': f'{user.password}',
'password': f'{user.teampassword.password}',
})
mail = EmailMessage(
'Login credentials',
Expand All @@ -129,7 +129,5 @@ def get(self, request, user_id, token):
from_email=settings.EMAIL_HOST_USER)
mail.content_subtype = 'html'
mail.send()
else:
context['message'] = 'Registration complete. Please login'

return render(request, 'accounts/registration_complete.html', context)
25 changes: 25 additions & 0 deletions teams/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.1 on 2020-11-08 07:55

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


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='TeamPassword',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=10)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
8 changes: 7 additions & 1 deletion teams/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from django.db import models
from django.contrib.auth import get_user_model

# Create your models here.
User = get_user_model()


class TeamPassword(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
password = models.CharField(max_length=10)
3 changes: 3 additions & 0 deletions teams/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .forms import CreateTeamForm, UpdateTeamForm
from membership.models import Business, BusinessTeamMember, Subscription, Plan
from accounts.models import Profile
from teams.models import TeamPassword


User = get_user_model()
Expand Down Expand Up @@ -63,6 +64,8 @@ def post(self, request, *args, **kwargs):
team_obj.created_by = self.request.user

team_obj.save()
TeamPassword.objects.create(
user=team_obj, password=self.team_password)

# create profile
profile = Profile(user=team_obj)
Expand Down
12 changes: 12 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ <h5 class="my-0 mr-md-auto font-weight-normal">Django Saas</h5>
{% endif %}
</div>

{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
{{ message }}
</div>
{% endfor %}
{% endif %}

{% block content %}
{% endblock %}

Expand Down