Fix migrations or something

This commit is contained in:
Maxime Bloch 2020-07-22 04:28:01 +02:00
parent 5d5dd4febd
commit 87845eea66
6 changed files with 13 additions and 28 deletions

View file

@ -1,5 +1,6 @@
# Generated by Django 3.0.8 on 2020-07-22 02:18
# Generated by Django 3.0.8 on 2020-07-22 02:25
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
@ -9,6 +10,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
@ -27,6 +29,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('state', models.CharField(choices=[('I', 'Interested'), ('A', 'Admitted'), ('D', 'Denied')], max_length=1)),
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.Event')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]

View file

@ -1,23 +0,0 @@
# Generated by Django 3.0.8 on 2020-07-22 02:18
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),
('events', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='eventregistration',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]

View file

@ -43,7 +43,7 @@ def register_callback(req: HttpRequest):
raise OAuthException(f'username and id are expected values: {user}')
else:
logger.debug(f'Succesfully authenticated user: {user["username"]} with id: {user["id"]}')
validated_user = validate_user(user['zeus_id'], user['username'])
validated_user = validate_user(user['id'], user['username'])
login(req, validated_user)
redirect('/')
else:

View file

@ -1,4 +1,4 @@
# Generated by Django 3.0.8 on 2020-07-22 02:18
# Generated by Django 3.0.8 on 2020-07-22 02:25
from django.db import migrations, models
import django.utils.timezone

View file

@ -5,6 +5,11 @@
<title>Profile</title>
</head>
<body>
{% if user.is_authenticated %}
<p>{{ username }}</p>
{% else %}
<p>Not logged in</p>
<a href="/login/zeus/register">Login</a>
{% endif %}
</body>
</html>

View file

@ -3,4 +3,4 @@ from django.shortcuts import render
def profile(request):
render(request, "profile.html", {"username": request.user.username})
return render(request, "profile.html", {"username": request.user.username})