web/quotes: make login work
This commit is contained in:
parent
ee3299223a
commit
eb8abcacec
10 changed files with 44 additions and 22 deletions
|
@ -9,7 +9,7 @@ class BFOBAdapter(DefaultAccountAdapter):
|
||||||
|
|
||||||
|
|
||||||
class BFOBSocialAdapter(DefaultSocialAccountAdapter):
|
class BFOBSocialAdapter(DefaultSocialAccountAdapter):
|
||||||
def is_open_for_signup(self, request):
|
def is_open_for_signup(self, request, sociallogin):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def pre_social_login(self, request, sociallogin):
|
def pre_social_login(self, request, sociallogin):
|
||||||
|
|
|
@ -2,5 +2,4 @@ from django.contrib import admin
|
||||||
from . import models
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(models.Person)
|
|
||||||
admin.site.register(models.Quote)
|
admin.site.register(models.Quote)
|
||||||
|
|
20
web/quotes/quotedb/migrations/0003_auto_20210120_2204.py
Normal file
20
web/quotes/quotedb/migrations/0003_auto_20210120_2204.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.1.5 on 2021-01-20 22:04
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("quotedb", "0002_auto_20210120_0039"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="quote",
|
||||||
|
name="references",
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name="Person",
|
||||||
|
),
|
||||||
|
]
|
|
@ -4,24 +4,10 @@ from django.db import models
|
||||||
from django.contrib.auth import models as auth_models
|
from django.contrib.auth import models as auth_models
|
||||||
|
|
||||||
|
|
||||||
class Person(models.Model):
|
|
||||||
name = models.CharField(null=False, unique=True, blank=False, max_length=120)
|
|
||||||
user = models.ForeignKey(
|
|
||||||
auth_models.User, null=True, default=None, on_delete=models.SET_NULL
|
|
||||||
)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name_plural = "people"
|
|
||||||
|
|
||||||
|
|
||||||
class Quote(models.Model):
|
class Quote(models.Model):
|
||||||
quote = models.TextField(null=False, blank=False)
|
quote = models.TextField(null=False, blank=False)
|
||||||
added_by = models.ForeignKey(auth_models.User, on_delete=models.SET_NULL, null=True)
|
added_by = models.ForeignKey(auth_models.User, on_delete=models.SET_NULL, null=True)
|
||||||
added_at = models.DateTimeField(default=datetime.datetime.now)
|
added_at = models.DateTimeField(default=datetime.datetime.now)
|
||||||
references = models.ManyToManyField(Person)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.quote
|
return self.quote
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
def home(request):
|
def home(request):
|
||||||
return render(request, "quotedb/home.html", {})
|
random_quote = models.Quote.objects.all().order_by("?").first()
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"quotedb/home.html",
|
||||||
|
{
|
||||||
|
"quote": random_quote,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
|
@ -6,7 +6,7 @@ class LoginRequiredMiddleware:
|
||||||
self.get_response = get_response
|
self.get_response = get_response
|
||||||
|
|
||||||
def is_open_url(self, path_info):
|
def is_open_url(self, path_info):
|
||||||
return path_info.startswith('/accounts/')
|
return path_info.startswith("/accounts/")
|
||||||
|
|
||||||
def __call__(self, request):
|
def __call__(self, request):
|
||||||
if not self.is_open_url(request.path_info):
|
if not self.is_open_url(request.path_info):
|
||||||
|
|
|
@ -154,3 +154,6 @@ SOCIALACCOUNT_PROVIDERS = {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACCOUNT_EMAIL_VERIFICATION = "none"
|
||||||
|
SOCIALACCOUNT_EMAIL_VERIFICATION = "none"
|
||||||
|
|
|
@ -24,6 +24,9 @@ import quotes.quotedb.urls
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("accounts/", include(allauth.urls)),
|
path("accounts/", include(allauth.urls)),
|
||||||
path("accounts/logged_out/", TemplateView.as_view(template_name='account/logged_out.html')),
|
path(
|
||||||
|
"accounts/logged_out/",
|
||||||
|
TemplateView.as_view(template_name="account/logged_out.html"),
|
||||||
|
),
|
||||||
re_path(r"", include(quotes.quotedb.urls)),
|
re_path(r"", include(quotes.quotedb.urls)),
|
||||||
]
|
]
|
||||||
|
|
4
web/quotes/templates/quotedb/_quote.html
Normal file
4
web/quotes/templates/quotedb/_quote.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div>
|
||||||
|
<p><a href="/{{ quote.id }}/">#{{ quote.id }}</a></p>
|
||||||
|
<pre>{{ quote.quote }}</pre>
|
||||||
|
</div>
|
|
@ -5,7 +5,5 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2 class="text-bfobOrange font-bnto text-2xl">...were you expecting something?</h2>
|
<h2 class="text-bfobOrange font-bnto text-2xl">...were you expecting something?</h2>
|
||||||
|
|
||||||
<div class="flex justify-center content-center my-40">
|
{% include "quotedb/_quote.html" with quote=quote only %}
|
||||||
<img src="https://bfob.gg/bfobweb.svg" class="w-72">
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue