mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
Character stuff
This commit is contained in:
parent
4ca6c7dbb0
commit
f9d1770361
@ -52,7 +52,11 @@ INSTALLED_APPS = (
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django_evolution',
|
||||
'authentication',
|
||||
'portal',
|
||||
'registration',
|
||||
'evespecific',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
@ -68,7 +72,6 @@ ROOT_URLCONF = 'allianceauth.urls'
|
||||
|
||||
WSGI_APPLICATION = 'allianceauth.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
|
||||
|
||||
@ -96,10 +99,25 @@ USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.core.context_processors.debug',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.static',
|
||||
'django.core.context_processors.tz',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.core.context_processors.request',
|
||||
'util.context_processors.alliance_id',
|
||||
'util.context_processors.alliance_name'
|
||||
)
|
||||
|
||||
########## USER CONFIGURATION
|
||||
AUTH_USER_MODEL = 'authentication.AllianceUser'
|
||||
########## END USER CONFIGURATION
|
||||
|
||||
LOGIN_URL = '/loginuser/'
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.6/howto/static-files/
|
||||
|
||||
@ -112,3 +130,7 @@ STATICFILES_DIRS = (
|
||||
)
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# ALLIANCE INFO
|
||||
ALLIANCE_ID = 99001336
|
||||
ALLIANCE_NAME = 'The 99 Percent'
|
||||
|
@ -8,6 +8,8 @@ urlpatterns = patterns('',
|
||||
# url(r'^$', 'allianceauth.views.home', name='home'),
|
||||
# url(r'^blog/', include('blog.urls')),
|
||||
url(r'^$', 'portal.views.index', name='index'),
|
||||
url(r'^characters/', 'portal.views.characters_view', name='characters'),
|
||||
url(r'^apimanagment/', 'portal.views.apimanagment_view', name='apimanagment'),
|
||||
url(r'^loginuser/','authentication.views.login_user', name='loginuser'),
|
||||
url(r'^logoutuser/','authentication.views.logout_user', name='logoutuser'),
|
||||
url(r'^register/', 'registration.views.register', name='register'),
|
||||
|
@ -1,7 +1,6 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import BaseUserManager
|
||||
from django.contrib.auth.models import AbstractBaseUser
|
||||
|
||||
# Todo Add a check to make sure the email / username has not been used before
|
||||
|
||||
class AllianceUserManager(BaseUserManager):
|
||||
@ -40,8 +39,8 @@ class AllianceUserManager(BaseUserManager):
|
||||
user.set_username(username)
|
||||
user.set_email(email)
|
||||
user.set_password(password)
|
||||
user.set_api_id(api_id)
|
||||
user.set_api_key(api_key)
|
||||
user.api_id = api_id
|
||||
user.api_key = api_key
|
||||
user.save(using=self._db)
|
||||
return user
|
||||
|
||||
@ -66,6 +65,7 @@ class AllianceUser(AbstractBaseUser):
|
||||
is_banned = models.BooleanField(default = False)
|
||||
api_id = models.CharField(max_length = 254)
|
||||
api_key = models.CharField(max_length = 254)
|
||||
|
||||
objects = AllianceUserManager()
|
||||
|
||||
USERNAME_FIELD = 'username'
|
||||
|
0
evespecific/__init__.py
Normal file
0
evespecific/__init__.py
Normal file
3
evespecific/admin.py
Normal file
3
evespecific/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
60
evespecific/managers.py
Normal file
60
evespecific/managers.py
Normal file
@ -0,0 +1,60 @@
|
||||
import evelink.api # Raw API access
|
||||
import evelink.char # Wrapped API access for the /char/ API path
|
||||
import evelink.eve # Wrapped API access for the /eve/ API path
|
||||
|
||||
from models import EveCharacter
|
||||
|
||||
class EveCharacterManager():
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def create_character(self,character_id, character_name,corporation_id,
|
||||
corporation_name, alliance_id,
|
||||
alliance_name, allianceuser_owner):
|
||||
|
||||
eve_char = EveCharacter();
|
||||
eve_char.character_id = character_id
|
||||
eve_char.character_name = character_name
|
||||
eve_char.corporation_id = corporation_id
|
||||
eve_char.corporation_name = corporation_name
|
||||
eve_char.alliance_id = alliance_id
|
||||
eve_char.alliance_name = alliance_name
|
||||
eve_char.allianceuser_owner = allianceuser_owner
|
||||
|
||||
eve_char.save()
|
||||
|
||||
def get_characters_by_owner_id(self, owner_id):
|
||||
return EveCharacter.objects.all().filter(allianceuser_owner=owner_id)
|
||||
|
||||
class EveApiManager():
|
||||
|
||||
characterManager = EveCharacterManager()
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def CreateCharactersFromID(self,api_id, api_key, user):
|
||||
# Create user
|
||||
api = evelink.api.API(api_key=(api_id, api_key))
|
||||
# Should get characters
|
||||
account = evelink.account.Account(api=api)
|
||||
chars = account.characters()
|
||||
|
||||
# Have our characters now lets populate database
|
||||
for char in chars.result:
|
||||
self.characterManager.create_character( chars.result[char]['id'], chars.result[char]['name'],
|
||||
chars.result[char]['corp']['id'], chars.result[char]['corp']['name'],
|
||||
chars.result[char]['alliance']['id'],chars.result[char]['alliance']['name'],
|
||||
user)
|
||||
#Done
|
||||
|
||||
def GetCorpNameByKey(self, api_id, api_key):
|
||||
pass
|
||||
|
||||
def GetAllianceNameByKey(self, api_id, api_key):
|
||||
pass
|
||||
|
||||
def GetCharactersByKey(self, api_id, api_key):
|
||||
pass
|
||||
|
13
evespecific/models.py
Normal file
13
evespecific/models.py
Normal file
@ -0,0 +1,13 @@
|
||||
from django.db import models
|
||||
|
||||
from authentication.models import AllianceUser
|
||||
|
||||
# Create your models here.
|
||||
class EveCharacter(models.Model):
|
||||
character_id = models.CharField(max_length=254)
|
||||
character_name = models.CharField(max_length=254)
|
||||
corporation_id = models.CharField(max_length=254)
|
||||
corporation_name = models.CharField(max_length=254)
|
||||
alliance_id = models.CharField(max_length=254)
|
||||
alliance_name = models.CharField(max_length=254)
|
||||
allianceuser_owner = models.ForeignKey(AllianceUser)
|
3
evespecific/tests.py
Normal file
3
evespecific/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
evespecific/views.py
Normal file
3
evespecific/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
@ -1,3 +1 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
@ -1,8 +1,23 @@
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render_to_response
|
||||
from django.template import RequestContext
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
from evespecific.managers import EveCharacterManager
|
||||
|
||||
# Create your views here.
|
||||
@login_required
|
||||
def index(request):
|
||||
return render_to_response('public/index.html',None, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def characters_view(request):
|
||||
characterManager = EveCharacterManager()
|
||||
|
||||
render_items = {'characters':characterManager.get_characters_by_owner_id(request.user.id)}
|
||||
return render_to_response('public/characters.html', render_items, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def apikeymanagment_view(request):
|
||||
render_items = {}
|
||||
return render_to_response('public/apikeymanagment.html', render_items, context_instance=RequestContext(request))
|
||||
|
@ -2,16 +2,17 @@ from django.http import Http404,HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response, render
|
||||
from django.template import RequestContext
|
||||
from authentication.models import AllianceUserManager
|
||||
from evespecific.managers import EveApiManager
|
||||
|
||||
from forms import RegistrationForm
|
||||
|
||||
# Create your views here.
|
||||
def register(request):
|
||||
if request.method == 'POST':
|
||||
form = RegistrationForm(request.POST)
|
||||
|
||||
if form.is_valid():
|
||||
userManager = AllianceUserManager()
|
||||
userManager.create_user_withapi(
|
||||
user = userManager.create_user_withapi(
|
||||
form.cleaned_data['username'],
|
||||
form.cleaned_data['email'],
|
||||
form.cleaned_data['password'],
|
||||
@ -19,6 +20,10 @@ def register(request):
|
||||
form.cleaned_data['api_key']
|
||||
)
|
||||
|
||||
# Populate character data
|
||||
api = EveApiManager()
|
||||
api.CreateCharactersFromID(form.cleaned_data['api_id'], form.cleaned_data['api_key'], user)
|
||||
|
||||
return HttpResponseRedirect("/")
|
||||
else:
|
||||
form = RegistrationForm()
|
||||
|
82
static/css/updatecards.css
Normal file
82
static/css/updatecards.css
Normal file
@ -0,0 +1,82 @@
|
||||
@import url(http://fonts.googleapis.com/css?family=Lato:400,700);
|
||||
body
|
||||
{
|
||||
font-family: 'Lato', 'sans-serif';
|
||||
}
|
||||
.profile
|
||||
{
|
||||
min-height: 150px;
|
||||
width: 350px;
|
||||
display: inline-block;
|
||||
}
|
||||
figcaption.ratings
|
||||
{
|
||||
margin-top:20px;
|
||||
}
|
||||
figcaption.ratings a
|
||||
{
|
||||
color:#f1c40f;
|
||||
font-size:11px;
|
||||
}
|
||||
figcaption.ratings a:hover
|
||||
{
|
||||
color:#f39c12;
|
||||
text-decoration:none;
|
||||
}
|
||||
.divider
|
||||
{
|
||||
border-top:1px solid rgba(0,0,0,0.1);
|
||||
}
|
||||
.emphasis
|
||||
{
|
||||
border-top: 4px solid transparent;
|
||||
}
|
||||
.emphasis:hover
|
||||
{
|
||||
border-top: 4px solid #1abc9c;
|
||||
}
|
||||
.emphasis h2
|
||||
{
|
||||
margin-bottom:0;
|
||||
}
|
||||
span.tags
|
||||
{
|
||||
background: #1abc9c;
|
||||
border-radius: 2px;
|
||||
color: #f5f5f5;
|
||||
font-weight: bold;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
.dropdown-menu
|
||||
{
|
||||
background-color: #34495e;
|
||||
box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
width: 250px;
|
||||
margin-left: -125px;
|
||||
left: 50%;
|
||||
}
|
||||
.dropdown-menu .divider
|
||||
{
|
||||
background:none;
|
||||
}
|
||||
.dropdown-menu>li>a
|
||||
{
|
||||
color:#f5f5f5;
|
||||
}
|
||||
.dropup .dropdown-menu
|
||||
{
|
||||
margin-bottom:10px;
|
||||
}
|
||||
.dropup .dropdown-menu:before
|
||||
{
|
||||
content: "";
|
||||
border-top: 10px solid #34495e;
|
||||
border-right: 10px solid transparent;
|
||||
border-left: 10px solid transparent;
|
||||
position: absolute;
|
||||
bottom: -10px;
|
||||
left: 50%;
|
||||
margin-left: -10px;
|
||||
z-index: 10;
|
||||
}
|
0
templates/public/apikeymanagment.html
Normal file
0
templates/public/apikeymanagment.html
Normal file
@ -14,6 +14,7 @@
|
||||
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
|
||||
|
||||
<link href="{% static 'css/dashboard.css' %}" rel="stylesheet">
|
||||
<link href="{% static 'css/updatecards.css' %}" rel="stylesheet">
|
||||
{% block extra_css %}{% endblock extra_css %}
|
||||
</head>
|
||||
|
||||
@ -28,7 +29,7 @@
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">{% block allianceName %} The 99 Percent {% endblock allianceName %}</a>
|
||||
<a class="navbar-brand" href="#">{{ ALLIANCE_NAME }}</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
@ -48,9 +49,9 @@
|
||||
{% if user.is_authenticated %}
|
||||
<div class="col-sm-3 col-md-2 sidebar">
|
||||
<ul class="nav nav-sidebar">
|
||||
<li class="active"><a href="#">Overview</a></li>
|
||||
<li><a href="#">Character</a></li>
|
||||
<li><a href="#">Api Keys</a></li>
|
||||
<li><a href="/">Overview</a></li>
|
||||
<li><a href="/characters">Characters</a></li>
|
||||
<li><a href="/apimanagment">Api Keys</a></li>
|
||||
<li><a href="#">Applications</a></li>
|
||||
<li><a href="#">Help</a></li>
|
||||
</ul>
|
||||
|
36
templates/public/characters.html
Normal file
36
templates/public/characters.html
Normal file
@ -0,0 +1,36 @@
|
||||
{% extends "public/base.html" %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block title %}Alliance Auth{% endblock %}
|
||||
|
||||
{% block page_title %}Something something here{% endblock page_title %}
|
||||
{% block extra_css %}{% endblock extra_css %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
{% for character in characters %}
|
||||
<div class="row">
|
||||
<div class="col-md-offset-2 col-md-8 col-lg-offset-3 col-lg-6">
|
||||
<div class="well well-sm profile">
|
||||
<div class="col-sm-12">
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<h3>{{character.character_name}}</h3>
|
||||
<p><strong>Corporation: </strong>{{character.corporation_name}}</p>
|
||||
<p><strong>Alliance: </strong> {{character.alliance_name}} </p>
|
||||
</div>
|
||||
<div class="col-xs-8 col-sm-4 text-center">
|
||||
<figure>
|
||||
<img src="https://image.eveonline.com/Character/{{character.character_id}}_128.jpg" alt="" class="img-responsive">
|
||||
</figure>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-offset-8">
|
||||
<button type="button" class="btn btn-primary">Make Primary</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
@ -7,6 +7,9 @@
|
||||
{% block content %}
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
|
||||
<h1 class="page-header">Dashboard</h1>
|
||||
<h1 class="page-header">Dashboard</h1>
|
||||
<div class="container">
|
||||
<p>WAT</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
@ -15,6 +15,7 @@
|
||||
{{form.as_p}}
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
|
||||
</form>
|
||||
<p><a href="/register/">Register Here</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
17
test.py
Normal file
17
test.py
Normal file
@ -0,0 +1,17 @@
|
||||
import evelink.api # Raw API access
|
||||
import evelink.char # Wrapped API access for the /char/ API path
|
||||
import evelink.eve # Wrapped API access for the /eve/ API path
|
||||
|
||||
api_id = '3730269'
|
||||
api_key = 'BkoREwPBo4QQOGGZXcuOfXMMfSDuTttmoqtQSjiaCoYECqrPozBp4bKjYZ2XmOHL'
|
||||
# Create user
|
||||
api = evelink.api.API(api_key=(api_id, api_key))
|
||||
account = evelink.account.Account(api=api)
|
||||
chars = account.characters()
|
||||
for char in chars.result:
|
||||
print char['alliance']['id']
|
||||
print char['alliance']['name']
|
||||
print char['corp']['id']
|
||||
print char['corp']['name']
|
||||
print char['id']
|
||||
print char['name']
|
0
util/__init__.py
Normal file
0
util/__init__.py
Normal file
9
util/context_processors.py
Normal file
9
util/context_processors.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.conf import settings # import the settings file
|
||||
|
||||
def alliance_id(request):
|
||||
# return the value you want as a dictionnary. you may add multiple values in there.
|
||||
return {'ALLIANCE_ID': settings.ALLIANCE_ID}
|
||||
|
||||
def alliance_name(request):
|
||||
# return the value you want as a dictionnary. you may add multiple values in there.
|
||||
return {'ALLIANCE_NAME': settings.ALLIANCE_NAME}
|
Loading…
x
Reference in New Issue
Block a user