Initial commit
This commit is contained in:
0
minecraft/__init__.py
Normal file
0
minecraft/__init__.py
Normal file
4
minecraft/admin.py
Normal file
4
minecraft/admin.py
Normal file
@@ -0,0 +1,4 @@
|
||||
import models
|
||||
from django.contrib import admin
|
||||
admin.site.register(models.MinecraftProfile)
|
||||
admin.site.register(models.Quote)
|
5
minecraft/context.py
Normal file
5
minecraft/context.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import models
|
||||
|
||||
def random_quote(request):
|
||||
quote = models.Quote.objects.order_by('?')[0]
|
||||
return {'quote': quote}
|
15
minecraft/models.py
Normal file
15
minecraft/models.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
class MinecraftProfile(models.Model):
|
||||
user = models.OneToOneField(User)
|
||||
mc_username = models.CharField(max_length=30)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.mc_username
|
||||
|
||||
class Quote(models.Model):
|
||||
text = models.CharField(max_length=50)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.text
|
16
minecraft/tests.py
Normal file
16
minecraft/tests.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
This file demonstrates writing tests using the unittest module. These will pass
|
||||
when you run "manage.py test".
|
||||
|
||||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.assertEqual(1 + 1, 2)
|
5
minecraft/urls.py
Normal file
5
minecraft/urls.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.conf.urls.defaults import patterns, include, url
|
||||
|
||||
urlpatterns = patterns('minecraft',
|
||||
url(r'^profile$', 'views.profile', name='user_profile'),
|
||||
)
|
7
minecraft/views.py
Normal file
7
minecraft/views.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render_to_response
|
||||
from django.template import RequestContext
|
||||
|
||||
@login_required
|
||||
def profile(request):
|
||||
return render_to_response('minecraft/profile.html', context_instance = RequestContext(request))
|
Reference in New Issue
Block a user