Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Player List and Detail page.

  • Loading branch information...
commit 998f1df2ba619b6ced8da5bd3481c79491ffee37 1 parent 605c432
@issackelly authored
View
2  profiles/models.py
@@ -6,3 +6,5 @@ class Player(models.Model):
username = models.CharField(max_length=64, unique=True)
battle_net_url = models.URLField(help_text="Go to http://us.battle.net/sc2/en/ and click on your avatar to go to your profile URL", blank=True)
+ def __unicode__(self):
+ return self.username
View
12 profiles/views.py
@@ -0,0 +1,12 @@
+from django.views.generic.detail import DetailView
+from django.views.generic.list import ListView
+from profiles.models import Player
+
+
+class PlayerView(DetailView):
+ queryset = Player.objects.all()
+ slug_field = 'username'
+ slug_url_kwarg = 'username'
+
+class PlayerList(ListView):
+ queryset = Player.objects.all().order_by('username')
View
13 sc2tourney/templates/profiles/player_detail.html
@@ -0,0 +1,13 @@
+{% extends "site_base.html" %}
+{% load staticfiles %}
+
+{% block head_title %}{{ object }} {{ block.super }}{% endblock %}
+
+{% block body %}
+<div class="span9">
+ <h1>{{ object }}</h1>
+ <h2><a href="{{ object.battle_net_url }}">Profile URL</a></h2>
+</div>
+<div class="span3">
+</div>
+{% endblock %}
View
20 sc2tourney/templates/profiles/player_list.html
@@ -0,0 +1,20 @@
+{% extends "site_base.html" %}
+{% load staticfiles pagination_tags %}
+{% load url from future %}
+
+{% block head_title %}{{ object }} {{ block.super }}{% endblock %}
+
+{% block body %}
+<div class="span9">
+ {% autopaginate object_list %}
+ <h1>All Players</h1>
+ {% for o in object_list %}
+ <div class="span6">
+ <h4><a href="{% url 'player_detail' o.username %}">{{ o }}</a></h4>
+ </div>
+ {% endfor %}
+ {% paginate %}
+</div>
+<div class="span3">
+</div>
+{% endblock %}
View
1  sc2tourney/templates/sc2match/match_detail.html
@@ -6,6 +6,7 @@
{% block body %}
<div class="span9">
<h1>{{ object }}</h1>
+ <h2><a href="{{ object.replay_file.url }}">Download Replay</a></h2>
</div>
<div class="span3">
</div>
View
2  sc2tourney/templates/sc2match/match_list.html
@@ -11,7 +11,7 @@
{% for o in object_list %}
<div class="span6">
<h4><a href="{% url 'match_detail' o.id %}">{{ o }}</a></h4>
- <div>
+ </div>
{% endfor %}
{% paginate %}
</div>
View
1  sc2tourney/templates/site_base.html
@@ -20,6 +20,7 @@
<ul class="nav">
<li><a href="/t/pycon">Bracket</a></li>
<li><a href="/sc2/match/">Latest Matches</a></li>
+ <li><a href="/accounts/">Players</a></li>
<li><a href="/about/">About</a></li>
{% if not request.user.is_authenticated %}
<li><a href="/accounts/register/">Register</a></li>
View
3  sc2tourney/urls.py
@@ -5,9 +5,12 @@
admin.autodiscover()
+from profiles.views import PlayerView, PlayerList
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
+ url(r'^accounts/$', PlayerList.as_view(), name="player_list"),
+ url(r'^accounts/(?P<username>[\w0-9\.\-]+)/', PlayerView.as_view(), name="player_detail"),
(r'^accounts/', include('profiles.backends.urls')),
url(r'^$', direct_to_template, {"template": "homepage.html"}, name="home"),
Please sign in to comment.
Something went wrong with that request. Please try again.