web/quotes: add some styling to some things

This commit is contained in:
Luke Granger-Brown 2021-01-20 03:16:29 +00:00
parent d8d2a0affa
commit 54bece932e
17 changed files with 156 additions and 37 deletions

View file

@ -15,7 +15,9 @@ class BFOBSocialAdapter(DefaultSocialAccountAdapter):
def pre_social_login(self, request, sociallogin): def pre_social_login(self, request, sociallogin):
guild_data = sociallogin.account.extra_data.get("guild_data", {}) guild_data = sociallogin.account.extra_data.get("guild_data", {})
roles = set(guild_data.get("roles", [])) roles = set(guild_data.get("roles", []))
should_be_admin = str(settings.DISCORD_ADMIN_ROLE) in roles should_be_admin = str(settings.DISCORD_ADMIN_ROLE) in roles or (
settings.DEBUG and guild_data == {}
)
user = sociallogin.user user = sociallogin.user
if user.is_staff != should_be_admin or user.is_superuser != should_be_admin: if user.is_staff != should_be_admin or user.is_superuser != should_be_admin:
user.is_staff = should_be_admin user.is_staff = should_be_admin

View file

@ -15,6 +15,8 @@ class DiscordGuildPermissionsOAuth2Adapter(DiscordOAuth2Adapter):
def complete_login(self, request, app, token, **kwargs): def complete_login(self, request, app, token, **kwargs):
login = super().complete_login(request, app, token, **kwargs) login = super().complete_login(request, app, token, **kwargs)
if settings.DISCORD_BOT_TOKEN is None and settings.DEBUG:
return login
guild_data = requests.get( guild_data = requests.get(
f"https://discord.com/api/guilds/{settings.DISCORD_GUILD_ID}/members/{login.account.uid}", f"https://discord.com/api/guilds/{settings.DISCORD_GUILD_ID}/members/{login.account.uid}",
headers={ headers={

View file

@ -1,2 +1,8 @@
[tool.black] [tool.black]
target-version = ['py38'] target-version = ['py38']
exclude = '''
(
theme/static
| theme/static_src
)
'''

View file

@ -138,6 +138,7 @@ STATICFILES_DIRS = [
BASE_DIR / "static", BASE_DIR / "static",
] ]
LOGIN_REDIRECT_URL = "/"
LOGIN_URL = "/accounts/discord/login/" LOGIN_URL = "/accounts/discord/login/"
ACCOUNT_ADAPTER = "quotes.discordguild.adapter.BFOBAdapter" ACCOUNT_ADAPTER = "quotes.discordguild.adapter.BFOBAdapter"
SOCIALACCOUNT_ADAPTER = "quotes.discordguild.adapter.BFOBSocialAdapter" SOCIALACCOUNT_ADAPTER = "quotes.discordguild.adapter.BFOBSocialAdapter"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,26 @@
/**
* @license
* MyFonts Webfont Build ID 3688122, 2018-12-14T12:37:09-0500
*
* The fonts listed in this notice are subject to the End User License
* Agreement(s) entered into by the website owner. All other parties are
* explicitly restricted from using the Licensed Webfonts(s).
*
* You may obtain a valid license at the URLs below.
*
* Webfont: BigNoodleTooOblique by Sentinel Type
* URL: https://www.myfonts.com/fonts/sentinel/big-noodle-too/oblique/
*
* Webfont: BigNoodleToo by Sentinel Type
* URL: https://www.myfonts.com/fonts/sentinel/big-noodle-too/regular/
*
*
* License: https://www.myfonts.com/viewlicense?type=web&buildid=3688122
* Licensed pageviews: 20,000
* Webfonts copyright: Copyright (c) James Arboghast/Sentinel Type, 2014. All rights reserved. Published 2014 by S E N T I N E L T Y P E. This font is authorized for use by Sentinel Type licensees of Blizzard Entertainment Inc, only & may not be copied or distributed.
*
* © 2018 MyFonts Inc
*/
@import url("//hello.myfonts.net/count/3846ba");
@font-face {font-family: 'BigNoodleTooOblique';src: url('3846BA_0_0.eot');src: url('3846BA_0_0.eot?#iefix') format('embedded-opentype'),url('3846BA_0_0.woff2') format('woff2'),url('3846BA_0_0.woff') format('woff'),url('3846BA_0_0.ttf') format('truetype');}
@font-face {font-family: 'BigNoodleToo';src: url('3846BA_1_0.eot');src: url('3846BA_1_0.eot?#iefix') format('embedded-opentype'),url('3846BA_1_0.woff2') format('woff2'),url('3846BA_1_0.woff') format('woff'),url('3846BA_1_0.ttf') format('truetype');}

View file

@ -0,0 +1,29 @@
{% extends "alert.html" %}
{% load i18n %}
{% load account socialaccount %}
{% block title %}Log In{% endblock %}
{% block content_title %}Log In{% endblock %}
{% block content_wrap %}
{% get_providers as socialaccount_providers %}
<a href="/accounts/discord/login/" class="text-3xl text-bfobOrange border border-bfobOrange inline-block my-5 p-3 w-full text-center">Sign in with Discord</a>
<p>...or</p>
<form method="POST" action="{% url 'account_login' %}">
{% csrf_token %}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<div class="grid grid-cols-formSideBySide gap-4 my-5">
<label class="text-right" for="login">Username:</label> {{ form.login }}
<label class="text-right" for="password">Password:</label> {{ form.password }}
<button class="border border-bfobGray col-span-2 p-2" type="submit">{% trans "Log In" %}</button>
</div>
</form>
{% endblock %}

View file

@ -0,0 +1,6 @@
{% extends "alert.html" %}
{% block title %}Signup Closed{% endblock %}
{% block content_title %}Signup <span class="text-bfobOrange">Closed</span>{% endblock %}
{% block content_text %}Only login via Discord is enabled.{% endblock %}

View file

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block content_extra_classes %}flex justify-center{% endblock %}
{% block content %}
<div class="w-4/6 m-8">
<h1 class="text-7xl font-bnto uppercase">
{% block content_title %}{% endblock %}
</h1>
{% block content_wrap %}
<p class="text-3xl">{% block content_text %}{% endblock %}</p>
{% endblock %}
</div>
{% endblock %}

View file

@ -1,2 +1,42 @@
{% load static %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>{% block fulltitle %}{% block title %}{% endblock title %} | BFOB Quotes{% endblock %}</title>
<link rel="stylesheet" href="{% static 'webfonts/fonts.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
</head>
<body class="bg-bfobGray-dark text-bfobGray font-serif leading-normal tracking-normal">
<div class="container mx-auto">
<section class="flex justify-between items-center"><!--flex items-center justify-center h-screen"-->
<h1 class="text-5xl font-bnto uppercase">
<a href="/">
BFOB <span class="text-bfobOrange">Quotes</span>
</a>
</h1>
<div>
{% if user.is_authenticated %}
<form action="/accounts/logout/" method="POST">
{% csrf_token %}
<button type="submit" class="px-4 py-1 rounded-full text-sm border border-bfobOrange text-bfobOrange hover:border-transparent hover:bg-bfobOrange hover:text-bfobGray-dark">Logout</button>
</form>
{% else %}
<a href="/accounts/discord/login/?process=login&next={{ request.path }}" class="px-4 py-1 rounded-full text-sm border border-bfobOrange text-bfobOrange hover:border-transparent hover:bg-bfobOrange hover:text-bfobGray-dark">Login</a>
{% endif %}
</div>
</section>
</div>
<div class="container mx-auto {% block content_extra_classes %}{% endblock %}">
{% block content %}{% endblock %}
</div>
</body>
</html>

View file

@ -1 +1,11 @@
hi {% extends "base.html" %}
{% block fulltitle %}BFOB Quotes{% endblock %}
{% block content %}
<h2 class="text-bfobOrange font-bnto text-2xl">...were you expecting something?</h2>
<div class="flex justify-center content-center my-40">
<img src="https://bfob.gg/bfobweb.svg" class="w-72">
</div>
{% endblock %}

View file

@ -2,4 +2,4 @@ from django.apps import AppConfig
class ThemeConfig(AppConfig): class ThemeConfig(AppConfig):
name = 'theme' name = "theme"

View file

@ -3,15 +3,27 @@
// https://unpkg.com/browse/tailwindcss@latest/stubs/defaultConfig.stub.js // https://unpkg.com/browse/tailwindcss@latest/stubs/defaultConfig.stub.js
module.exports = { module.exports = {
purge: [ purge: [
// Templates within theme app (e.g. base.html)
'../templates/**/*.html', '../templates/**/*.html',
// Templates in other apps. Uncomment the following line if it matches '../../templates/**/*.html',
// your project structure or change it to match.
// '../../templates/**/*.html',
], ],
darkMode: false, // or 'media' or 'class' darkMode: false, // or 'media' or 'class'
theme: { theme: {
extend: {}, extend: {
colors: {
bfobGray: {
dark: '#373535',
DEFAULT: '#7E7F7F',
},
bfobOrange: '#F48735',
},
fontFamily: {
bnto: ['BigNoodleTooOblique'],
bnt: ['BigNoodleToo'],
},
gridTemplateColumns: {
formSideBySide: 'minmax(150px, min-content) minmax(0, 1fr)',
},
},
}, },
variants: { variants: {
extend: {}, extend: {},

View file

@ -1,29 +0,0 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tailwind CSS Skeleton</title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
</head>
<body class="bg-grey-lightest font-serif leading-normal tracking-normal">
<div class="container mx-auto">
<section class="flex items-center justify-center h-screen">
<h1 class="text-5xl">Django + Tailwind = ❤️</h1>
</section>
</div>
</body>
</html>