added some base templates and basic css etc.

This commit is contained in:
2018-04-19 10:41:07 +01:00
parent 9e4a35ce98
commit 8213a1abd8
7 changed files with 116 additions and 6 deletions

View File

@@ -1,3 +1,36 @@
from django.shortcuts import render
from typing import Union
import requests
from django.contrib.auth.models import User
from django.shortcuts import render
from allauth.socialaccount.providers import eveonline
# Create your views here.
from allauth.socialaccount.models import SocialAccount, SocialToken, SocialApp
from requests.auth import HTTPBasicAuth
def hello(request):
return render(
request,
'base.html',
{}
)
def renew_token(request, account: Union[SocialAccount, User]):
if account is User:
account = SocialAccount.objects.get(user=account)
token = SocialToken.objects.get(account=account)
app = SocialApp.objects.get(provider='eveonline')
req = requests.post(
url='https://login.eveonline.com/oauth/token',
data={
'grant_type': 'refresh_token',
'refresh_token': token.token_secret
},
auth=HTTPBasicAuth(app.client_id, app.secret)
)
token.token = req.json()['access_token']
token.save()

View File

@@ -43,6 +43,7 @@ INSTALLED_APPS = [
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.eveonline',
'bootstrap4',
]
MIDDLEWARE = [
@@ -133,8 +134,16 @@ USE_TZ = True
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
EVE_CLIENT_ID = '2f398f82dbdb43ff86c60effcc423f93'
EVE_SECRET_KEY = 'xnaKPpbqoDH9LO8aE7FVq5Xb4aqI6guXeTBkdMB4'
SITE_ID = 1
SITE_ID = 1
SOCIALACCOUNT_STORE_TOKENS = True
SOCIALACCOUNT_PROVIDERS = {
'eveonline': {
'SCOPE': ['publicData', 'esi-characters.read_corporation_roles.v1', 'characterAccountRead']
}
}

View File

@@ -16,8 +16,10 @@ Including another URLconf
from django.conf.urls import url
from django.contrib import admin
from django.urls import path, include
import allauth
import eve_auth.views
urlpatterns = [
path('admin/', admin.site.urls),
url(r'^accounts/', include('allauth.urls')),
path('', eve_auth.views.hello)
]

View File

@@ -1,3 +1,4 @@
Django
requests
django-allauth
django-allauth
django-bootstrap4

7
static/css/custom.css Normal file
View File

@@ -0,0 +1,7 @@
body {
padding-top: 5rem;
}
.starter-template {
padding: 3rem 1.5rem;
text-align: center;
}

38
templates/base.html Normal file
View File

@@ -0,0 +1,38 @@
{% load bootstrap4 %}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Starter Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
{% bootstrap_css %}
<!-- Custom styles for this template -->
<link href="/static/css/custom.css" rel="stylesheet">
</head>
<body>
{% include 'nav.html' %}
<main role="main" class="container">
<div class="starter-template">
<h1>Bootstrap starter template</h1>
<p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
</div>
</main><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
{% bootstrap_javascript jquery='full' %}
</body>
</html>

20
templates/nav.html Normal file
View File

@@ -0,0 +1,20 @@
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="/">Eve Verify</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="/accounts/eveonline/login/">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Login</a>
</li>
</ul>
</div>
</nav>