Merge branch 'master' of dev.camin.us:www

Conflicts:
	profiles/models.py
	profiles/views.py
	templates/base_full.html
This commit is contained in:
Trever Fischer
2012-03-04 23:22:47 -05:00
10 changed files with 51 additions and 34 deletions

View File

@@ -6,7 +6,7 @@ class CurrencyAccount(models.Model):
profile = models.OneToOneField(MinecraftProfile)
username = models.CharField(max_length=255, unique=True, null=True)
balance = models.FloatField(default=3000)
status = models.IntegerField()
status = models.IntegerField(default=0)
def __unicode__(self):
return self.username

View File

@@ -54,6 +54,6 @@ class MOTD(models.Model):
def create_profile(sender, instance, created, **kwargs):
if created:
MinecraftProfile.objects.create(user=instance)
MinecraftProfile.objects.create(user=instance, mc_username=instance.username)
post_save.connect(create_profile, sender=User)

View File

@@ -1,3 +1,4 @@
import models
from django.contrib import admin
admin.site.register(models.Quote)
admin.site.register(models.Invite)

View File

@@ -7,6 +7,7 @@ from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
import django.contrib.auth
from django.contrib.auth import authenticate, login
from django.core.exceptions import ObjectDoesNotExist
import forms
import models
import shortuuid
@@ -72,18 +73,23 @@ def register(request):
userForm = forms.UserForm(prefix='user')
profileForm = ProfileForm(prefix='profile')
if userForm.is_valid() and profileForm.is_valid():
user = User()
user.username = userForm.cleaned_data['username']
user.email = userForm.cleaned_data['email']
user.set_password(userForm.cleaned_data['password'])
user.save()
invite.claimer = user
invite.save()
profile = user.minecraftprofile
profile.mc_username = profileForm.cleaned_data['mc_username']
profile.save()
del request.session['profile-invite']
return HttpResponseRedirect("/")
oldUser = None
try:
oldUser = User.objects.get(username__exact=userForm.cleaned_data['username'])
except ObjectDoesNotExist, e:
pass
if not oldUser:
user = User.objects.create_user(userForm.cleaned_data['username'], userForm.cleaned_data['email'], userForm.cleaned_data['password'])
user.save()
invite.claimer = user
invite.save()
profile = user.minecraftprofile()
profile.mc_username = profileForm.cleaned_data['mc_username']
profile.save()
user = django.contrib.auth.authenticate(userForm.cleaned_data['username'], userForm.cleaned_data['password'])
django.contrib.auth.login(request, user)
del request.session['profile-invite']
return HttpResponseRedirect("/")
return render_to_response('profiles/register.html', {'userForm': userForm, 'profileForm': profileForm, 'invite':invite}, context_instance = RequestContext(request))
@login_required

View File

@@ -227,14 +227,6 @@ tr.sticky a:link {
margin: 0;
}
#epicenter label {
float:left;
}
#epicenter input[type="text"] {
float:right;
}
#content input[type="text"], #content textarea {
width: 100%;
}
@@ -260,3 +252,13 @@ tr.sticky a:link {
padding: 3px;
text-align: center;
}
#epicenter ul {
list-style:none;
}
#epicenter ul a {
color: #fff;
font-size:large;
text-decoration: none;
}

View File

@@ -35,26 +35,24 @@
<h2 class="title">{{user.username}}</h2>
<div class="userbox">
<div class="avatar">
{% avatar user.minecraftprofile.mc_username %}
<a href="{%url user_profile %}">{% avatar user.minecraftprofile.mc_username %}</a>
</div>
<div class="balance">
<span id="balance-display">{{ user.minecraftprofile.currencyaccount.balance|floatformat:2 }}</span> grist
</div>
<div class="time">
<span id="time-display"></span>
</div>
</div>
<ul>
<li><a href="{% url user_profile %}">Profile</a></li>
<li><a href="{% url user_profile %}">Your Profile</a></li>
<li><a href="{% url profiles.views.logout %}">Logout</a></li>
{% if user.is_staff %}
{% if user.is_staff or user.is_superuser %}
<li><a href="{% url admin:index %}">Admin</a></li>
{% endif %}
</ul>
{% else %}
<h2 class="title">Login</h2>
<p>Welcome! Do you have an invite? <a href="{% url profiles.views.claimInvite %}">Claim it!</a><p>
<form method="POST" action="{%url profiles.views.login %}">
<p><a href="{% url django.contrib.auth.views.password_reset %}">Forgot your password?</a>
<form method="POST" action="{%url django.contrib.auth.views.login %}">
{%csrf_token%}
{{login_form.as_p}}
<input type="submit" value="Login"/>
@@ -91,6 +89,9 @@
<div class="grid_4">
<div id="statbox" class="stat-box">
<h2 class="title">World Status</h2>
<div class="time">
Current time: <span id="time-display"></span>
</div>
{% for server in minecraft_servers %}
<a href="http://{{server.hostname}}/map/">Live Map</a>
<h3>{{server.hostname}}:{{server.port}}</h3>

View File

@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base_simple.html" %}
{%block title%}Claim an Invite{%endblock%}
{%block content %}

View File

@@ -1,11 +1,17 @@
{% extends "profile_base.html" %}
{%block title%}Your Profile{%endblock%}
{% load minecraft %}
{%block title%}{{user}}{%endblock%}
{% block sectiontitle %}{{user}}{%endblock%}
{%block content %}
<div class="item">
<p>Welcome, {{ user.username }}</p>
{% avatar user %}
<a href="{%url profiles.views.edit %}">Edit profile</a>
<a href="{%url profiles.views.invites %}">Invites</a>
<ul>
<li>Member Since: {{user.date_joined|date:"SHORT_DATE_FORMAT"}}</li>
<li>Last seen: {{user.last_login|date:"SHORT_DATE_FORMAT"}}</li>
</ul>
</div>
{%endblock%}

View File

@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base_simple.html" %}
{%block title%}Register an Account{%endblock%}
{%block content %}

View File

@@ -11,6 +11,7 @@ urlpatterns = patterns('',
url(r'^news/', include('news.urls')),
url(r'^minecraft/', include('minecraft.urls')),
url(r'^profiles/', include('profiles.urls')),
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^forums/', include('forums.urls')),