diff --git a/allianceauth/settings.py b/allianceauth/settings.py index 61725ee1..2807bfe0 100644 --- a/allianceauth/settings.py +++ b/allianceauth/settings.py @@ -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' diff --git a/allianceauth/urls.py b/allianceauth/urls.py index 83977e7f..bbccb5f7 100644 --- a/allianceauth/urls.py +++ b/allianceauth/urls.py @@ -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'), diff --git a/authentication/models.py b/authentication/models.py index 6f981ac7..4e0f6d62 100644 --- a/authentication/models.py +++ b/authentication/models.py @@ -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' diff --git a/evespecific/__init__.py b/evespecific/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/evespecific/admin.py b/evespecific/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/evespecific/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/evespecific/managers.py b/evespecific/managers.py new file mode 100644 index 00000000..75bc4e63 --- /dev/null +++ b/evespecific/managers.py @@ -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 + \ No newline at end of file diff --git a/evespecific/models.py b/evespecific/models.py new file mode 100644 index 00000000..570653c9 --- /dev/null +++ b/evespecific/models.py @@ -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) \ No newline at end of file diff --git a/evespecific/tests.py b/evespecific/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/evespecific/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/evespecific/views.py b/evespecific/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/evespecific/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/portal/models.py b/portal/models.py index 71a83623..137941ff 100644 --- a/portal/models.py +++ b/portal/models.py @@ -1,3 +1 @@ from django.db import models - -# Create your models here. diff --git a/portal/views.py b/portal/views.py index 814844ad..1583abf0 100644 --- a/portal/views.py +++ b/portal/views.py @@ -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)) diff --git a/registration/views.py b/registration/views.py index 005956e5..83eafe3a 100644 --- a/registration/views.py +++ b/registration/views.py @@ -2,22 +2,27 @@ 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'], form.cleaned_data['api_id'], 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: diff --git a/static/css/updatecards.css b/static/css/updatecards.css new file mode 100644 index 00000000..e7cbbf1b --- /dev/null +++ b/static/css/updatecards.css @@ -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; + } \ No newline at end of file diff --git a/templates/public/apikeymanagment.html b/templates/public/apikeymanagment.html new file mode 100644 index 00000000..e69de29b diff --git a/templates/public/base.html b/templates/public/base.html index 7832f9eb..655c8ec5 100644 --- a/templates/public/base.html +++ b/templates/public/base.html @@ -14,6 +14,7 @@ + {% block extra_css %}{% endblock extra_css %} @@ -28,7 +29,7 @@ - {% block allianceName %} The 99 Percent {% endblock allianceName %} + {{ ALLIANCE_NAME }} diff --git a/test.py b/test.py new file mode 100644 index 00000000..cbc7fd15 --- /dev/null +++ b/test.py @@ -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'] diff --git a/util/__init__.py b/util/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/util/context_processors.py b/util/context_processors.py new file mode 100644 index 00000000..b40dcd2b --- /dev/null +++ b/util/context_processors.py @@ -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} \ No newline at end of file