mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Adds a character viewer
This commit is contained in:
@@ -16,6 +16,8 @@ urlpatterns = patterns('',
|
||||
(r'^profile/add/reddit', views.reddit_add),
|
||||
(r'^profile/del/reddit/$', views.reddit_del),
|
||||
(r'^profile/del/reddit/(?P<redditid>\d+)/$', views.reddit_del),
|
||||
(r'^profile/characters$', views.characters),
|
||||
(r'^profile/characters/(?P<charid>.*)/$', views.characters),
|
||||
(r'^users/(?P<user>.*)/$', views.user_view),
|
||||
(r'^users/$', views.user_view),
|
||||
)
|
||||
|
||||
24
sso/views.py
24
sso/views.py
@@ -10,7 +10,7 @@ from django.template import RequestContext
|
||||
|
||||
from eve_api.api_exceptions import APIAuthException, APINoUserIDException
|
||||
from eve_api.api_puller.accounts import import_eve_account
|
||||
from eve_api.models.api_player import EVEAccount
|
||||
from eve_api.models.api_player import EVEAccount, EVEPlayerCharacter
|
||||
|
||||
from sso.models import ServiceAccount, Service, SSOUser, ExistingUser
|
||||
from sso.forms import EveAPIForm, UserServiceAccountForm, RedditAccountForm, UserLookupForm
|
||||
@@ -49,6 +49,28 @@ def profile(request):
|
||||
|
||||
return render_to_response('sso/profile.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def characters(request, charid=0):
|
||||
|
||||
if charid:
|
||||
try:
|
||||
character = EVEPlayerCharacter.objects.get(id=charid)
|
||||
except EVEPlayerCharacter.DoesNotExist:
|
||||
return HttpResponseRedirect(reverse('sso.views.profile'))
|
||||
return render_to_response('sso/character.html', locals(), context_instance=RequestContext(request))
|
||||
try:
|
||||
eveaccounts = EVEAccount.objects.filter(user=request.user).all()
|
||||
characters = []
|
||||
for acc in eveaccounts:
|
||||
chars = acc.characters.all()
|
||||
for char in chars:
|
||||
characters.append({'id': char.id, 'name': char.name, 'corp': char.corporation.name})
|
||||
|
||||
except EVEAccount.DoesNotExist:
|
||||
characters = []
|
||||
|
||||
return render_to_response('sso/characterlist.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def eveapi_add(request):
|
||||
if request.method == 'POST':
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<li><a href="/">Home</a></li>
|
||||
{% if request.user %}
|
||||
<li><a href="/profile">Profile</a></li>
|
||||
<li><a href="/profile/characters">Characters</a></li>
|
||||
{% if request.user.is_staff %}
|
||||
<li><a href="/users">Lookup User</a></li>
|
||||
<li><a href="/admin">Admin</a></li>
|
||||
|
||||
Reference in New Issue
Block a user