kaputtnik has proposed merging lp:~widelands-dev/widelands-website/cleanup_ggz into lp:widelands-website.
Requested reviews: Widelands Developers (widelands-dev) For more details, see: https://code.launchpad.net/~widelands-dev/widelands-website/cleanup_ggz/+merge/301588 This branch contains cleanups for ggz/wlggz, but keeps the ggz_auth related things, which are used on the website. - removing ggz related code in templates and views - removed ggz-models I don't know how exactly the metaserver works in conjunction with widelands(game) and website(ggz_auth), but by looking in the code for the metaserver it seems to me that there are only three fields relevant: Username, Password and Permission. If this is right we could maybe also remove some fields in wlggz/models.py, namely: lastlogin = models.DateTimeField(_('ggz lastlogin'), null=True) confirmed = models.IntegerField(_('confirmed'), default=1, editable=False) But i think there is no need to remove this fields. The changes in local_settings.py.sample are some things i stumbled over, except the LOGGING thing: It took me some time to find out how this works and just wanted to have it documented somewhere. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/cleanup_ggz into lp:widelands-website.
=== modified file '.bzrignore' --- .bzrignore 2016-05-17 19:28:38 +0000 +++ .bzrignore 2016-07-31 12:32:05 +0000 @@ -6,7 +6,7 @@ # Uploaded images. media/news/* media/wlhelp/* -media/wlmaps/* +media/wlmaps/maps/* media/wlprofile/avatars/* media/wlscreens/* media/wlimages/* === modified file 'local_settings.py.sample' --- local_settings.py.sample 2016-06-26 11:30:10 +0000 +++ local_settings.py.sample 2016-07-31 12:32:05 +0000 @@ -19,8 +19,40 @@ # The following are just dummy values, but needed defined +# To use the registration you have to create an API key pair +# See https://developers.google.com/recaptcha/docs/start +# You have to use 'localhost' as Domain NORECAPTCHA_SITE_KEY = 'dummy' NORECAPTCHA_SECRET_KEY = 'dummy' # The logo used for mainpage LOGO_FILE = 'Logo_alpha.png' + +# Setting an email backend prevents 'connection refused' errors +# This Backend shows Emails in console +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +# Uncomment 'LOGGING = {...}' for debugging purposes when you have set DEBUG=False. +# Use then in the code: + +# import logging +# log = logging.getLogger(__name__) +# log.info('Variable x: %s', x) + +# This prints the value for Variable 'x' to log.txt + +#LOGGING = { +# 'version': 1, +# 'disable_existing_loggers': False, +# 'handlers': { +# 'logfile': { +# 'level':'DEBUG', +# 'class':'logging.FileHandler', +# 'filename': bd + "/log.txt", +# }, +# }, +# 'root': { +# 'level': 'INFO', +# 'handlers': ['logfile'] +# }, +#} === removed file 'media/css/ggz.css' --- media/css/ggz.css 2010-06-12 17:08:18 +0000 +++ media/css/ggz.css 1970-01-01 00:00:00 +0000 @@ -1,12 +0,0 @@ -.ggz_stats { - width: 120px; -} -.ggz_date { - width: 150px; -} -.ggz_winner { - width: 100px; -} -.ggz_vs { - width: 290px; -} === added directory 'media/wlmaps' === added directory 'media/wlmaps/maps' === modified file 'templates/pybb/inlines/post.html' --- templates/pybb/inlines/post.html 2016-06-06 18:26:47 +0000 +++ templates/pybb/inlines/post.html 2016-07-31 12:32:05 +0000 @@ -45,12 +45,6 @@ {% if post.user.wlprofile.location %} <strong>Location:</strong> {{ post.user.wlprofile.location }}<br /> {% endif %} - {% if post.user.wlprofile.get_ggzstats and post.user.wlprofile.get_ggzstats.ranking %} - <strong>GGZ ranking:</strong> {{ post.user.wlprofile.get_ggzstats.ranking|floatformat }}<br /> - <strong>GGZ rating:</strong> {{ post.user.wlprofile.get_ggzstats.rating|floatformat }}<br /> - <strong>GGZ win:</strong> {{ post.user.wlprofile.get_ggzstats.wins|floatformat }}<br /> - <strong>GGZ loses:</strong> {{ post.user.wlprofile.get_ggzstats.losses|floatformat }}<br /> - {% endif %} </div> </td> <td width="85%" class="content top"> === modified file 'templates/pybb/topic.html' --- templates/pybb/topic.html 2016-04-29 07:28:16 +0000 +++ templates/pybb/topic.html 2016-07-31 12:32:05 +0000 @@ -92,12 +92,6 @@ {% if post.user.wlprofile.location %} <strong>Location:</strong> {{ post.user.wlprofile.location }}<br /> {% endif %} - {% if post.user.wlprofile.get_ggzstats and post.user.wlprofile.get_ggzstats.ranking %} - <strong>GGZ ranking:</strong> {{ post.user.wlprofile.get_ggzstats.ranking|floatformat }}<br /> - <strong>GGZ rating:</strong> {{ post.user.wlprofile.get_ggzstats.rating|floatformat }}<br /> - <strong>GGZ win:</strong> {{ post.user.wlprofile.get_ggzstats.wins|floatformat }}<br /> - <strong>GGZ loses:</strong> {{ post.user.wlprofile.get_ggzstats.losses|floatformat }}<br /> - {% endif %} </div> </td> <td class="post"> @@ -179,12 +173,6 @@ {% if post.user.wlprofile.location %} <strong>Location:</strong> {{ post.user.wlprofile.location }}<br /> {% endif %} - {% if post.user.wlprofile.get_ggzstats and post.user.wlprofile.get_ggzstats.ranking %} - <strong>GGZ ranking:</strong> {{ post.user.wlprofile.get_ggzstats.ranking|floatformat }}<br /> - <strong>GGZ rating:</strong> {{ post.user.wlprofile.get_ggzstats.rating|floatformat }}<br /> - <strong>GGZ win:</strong> {{ post.user.wlprofile.get_ggzstats.wins|floatformat }}<br /> - <strong>GGZ loses:</strong> {{ post.user.wlprofile.get_ggzstats.losses|floatformat }}<br /> - {% endif %} </div> </td> <td class="post"> === removed file 'templates/wlggz/base.html' --- templates/wlggz/base.html 2015-02-18 22:30:08 +0000 +++ templates/wlggz/base.html 1970-01-01 00:00:00 +0000 @@ -1,12 +0,0 @@ -{% extends "base.html" %} -{% comment %} - vim:ft=htmldjango -{% endcomment %} - -{% block title %} -GGZ statistics - {{ block.super }} -{% endblock %} - -{% block extra_head %} -<link rel="stylesheet" type="text/css" media="all" href="{{ MEDIA_URL }}css/ggz.css" />{{ block.super}} -{% endblock %} === removed file 'templates/wlggz/view_ggz_highscore.html' --- templates/wlggz/view_ggz_highscore.html 2016-06-06 18:26:47 +0000 +++ templates/wlggz/view_ggz_highscore.html 1970-01-01 00:00:00 +0000 @@ -1,43 +0,0 @@ -{% extends "wlggz/base.html" %} - -{% load i18n %} - -{% block content %} -{% load custom_date %} -{% load wlprofile_extras %} - -{% include "django_messages/inlines/navigation.html" %} - -<br /> -<br /> -<div class="box_item_model fixed_site border"> - <h3 class="title">Top ten widelands players</h3> - <table cellspacing="1" class="text full_site"> - <tr> - <td>User</td> - <td>ranking</td> - <td>rating</td> - <td>wins</td> - <td>losses</td> - </tr> - {% for userstat in ggzstats %} - <tr> - <td class="{% cycle "odd" "even" %}"><a href="{% url 'wlggz_userstats' userstat.handle %}">{{ userstat.handle }}</a></td> - <td class="{% cycle "odd" "even" %}"> {{ userstat.ranking|floatformat }} </td> - <td class="{% cycle "odd" "even" %}"> {{ userstat.rating|floatformat }} </td> - <td class="{% cycle "odd" "even" %}"> {{ userstat.wins|floatformat }} </td> - <td class="{% cycle "odd" "even" %}"> {{ userstat.losses|floatformat }} </td> - </tr> - {% empty %} - <tr> - <td class="even show_center" colspan="5"> - <br /> - <b>Sorry, no ranking yet</b> - <br /> - <br /> - </td> - </tr> - {% endfor %} - </table> -</div> -{% endblock %} === removed file 'templates/wlggz/view_ggz_matches.html' --- templates/wlggz/view_ggz_matches.html 2016-03-02 21:02:38 +0000 +++ templates/wlggz/view_ggz_matches.html 1970-01-01 00:00:00 +0000 @@ -1,45 +0,0 @@ -{% extends "wlggz/base.html" %} - -{% load i18n %} - -{% block content %} -{% load custom_date %} -{% load wlprofile_extras %} - -{% include "django_messages/inlines/navigation.html" %} - -<br /> -<br /> -<div class="box_item_model fixed_site border"> - <h3 class="title">Last 10 matches</h3> - <table cellspacing="1" class="text full_site"> - <tr> - <td class="ggz_date">Date</td> - <td class="ggz_winner">Winner</td> - <td class="ggz_vs">Participants</td> - </tr> - {% for match in ggzmatches %} - <tr> - <td class="{% cycle "odd" "even" %}">{{ match.date_date }}</td> - <td class="{% cycle "odd" "even" %}"> - {{ match.winner_as_userlink }} - </td> - <td class="{% cycle "odd" "even" %}"> - {% for player in match.wlggz_matchplayers.all %} - {{ player.handle_as_userlink }}({{ player.result }}, {{ player.points }}) - {% endfor %} - </td> - </tr> - {% empty %} - <tr> - <td class="even show_center" colspan="3"> - <br /> - <b>Sorry, no matches yet</b> - <br /> - <br /> - </td> - </tr> - {% endfor %} - </table> -</div> -{% endblock %} === removed file 'templates/wlggz/view_ggz_overview.html' --- templates/wlggz/view_ggz_overview.html 2016-06-06 18:26:47 +0000 +++ templates/wlggz/view_ggz_overview.html 1970-01-01 00:00:00 +0000 @@ -1,27 +0,0 @@ -{% extends "wlggz/base.html" %} - -{% load i18n %} - -{% block content %} -{% load custom_date %} - -{% include "django_messages/inlines/navigation.html" %} -<br /> -<br /> -<div class="box_item_model fixed_site border"> - <h3 class="title">{% trans "Available Links" %}</h3> - <div class="info_line show_left"> - <br /> - <a href="{% url 'wlggz_matches' %}">Last matches</a><br /> - <a href="{% url 'wlggz_ranking' %}">GGZ ranking</a><br /> - <br /> - {% if user.is_authenticated %} - <a href="{% url 'wlggz_userstats' %}">View your ggz statistics</a><br /> - <a href="{% url 'wlggz_userinfo' %}">About your ggz account</a><br /> - <a href="{% url 'wlggz_changepw' %}">Change your ggz password</a><br /> - <br /> - {% endif %} - </div> -</div> - -{% endblock %} === removed file 'templates/wlggz/view_ggz_playerstats.html' --- templates/wlggz/view_ggz_playerstats.html 2016-03-02 21:02:38 +0000 +++ templates/wlggz/view_ggz_playerstats.html 1970-01-01 00:00:00 +0000 @@ -1,106 +0,0 @@ -{% extends "wlggz/base.html" %} - -{% load i18n %} - -{% block content %} -{% load custom_date %} -{% load wlprofile_extras %} - -{% include "django_messages/inlines/navigation.html" %} - -<br /> -<br /> - -{% if ggzauth.user %} - <div class="box_item_model fixed_site border"> - <h3 class="title">{% trans "GGZ results for" %} {{ ggzauth.user.username }}</h3> - <table class="info_line full_site"> - <tr><td class="ggz_stats">Last ggz login:</td><td class="show_left"> {{ ggzauth.lastlogin }}</td></tr> - <tr><td class="ggz_stats">Ranking:</td><td class="show_left"> {{ ggzstats.ranking }}</td></tr> - <tr><td class="ggz_stats">Rating:</td><td class="show_left"> {{ ggzstats.rating|floatformat }}</td></tr> - <tr><td class="ggz_stats">wins:</td><td class="show_left"> {{ ggzstats.wins }}</td></tr> - <tr><td class="ggz_stats">losses:</td><td class="show_left"> {{ ggzstats.losses }}</td></tr> - </table> - </div> - <br /> - <br /> - - <div class="box_item_model fixed_site border"> - <h3 class="title">Last 10 matches of {{ ggzauth.user.username }}</h3> - {% if ggzmatches %} - <table width="100%" cellspacing="1" class="text"> - <tr> - <td class="ggz_date">Date</td> - <td class="ggz_winner">Winner</td> - <td class="ggz_vs">Participants</td> - </tr> - {% for match in ggzmatches %} - <tr> - <td class="{% cycle "odd" "even" %}">{{ match.match.date_date }}</td> - <td class="{% cycle "odd" "even" %}"> - {% if match.match.winner %} - {{ match.match.winner_as_userlink }} - {% endif %} - </td> - <td class="{% cycle "odd" "even" %}"> - {% for player in match.match.wlggz_matchplayers.all %} - {{ player.handle_as_userlink }} - {% endfor %} - </td class="{% cycle "odd" "even" %}"> - </tr> - {% endfor %} - </table> - {% else %} - <div class="info_line show_center"> - <br /> - <b>User has not participated in any matches</b> - <br /> - <br /> - </div> - {% endif %} - </div> - <br /> - <br /> - <div class="box_item_model fixed_site border"> - <h3 class="title">Last 10 matches {{ ggzauth.user.username }} won</h3> - {% if ggzwonmatches %} - <table cellspacing="1" class="text full_site"> - <tr> - <td class="ggz_date">Date</td> - <td class="ggz_winner">Winner</td> - <td class="ggz_vs">Participants</td> - </tr> - {% for match in ggzwonmatches %} - <tr> - <td class="{% cycle "odd" "even" %}">{{ match.date_date }}</td> - <td class="{% cycle "odd" "even" %}">{{ match.winner_as_userlink }}</td> - <td class="{% cycle "odd" "even" %}"> - {% for player in match.wlggz_matchplayers.all %} - {{ player.handle_as_userlink }} - {% endfor %} - </td> - </tr> - {% endfor %} - </table> - {% else %} - <div class="info_line show_center"> - <br /> - <b>User has won no matches</b> - <br /> - <br /> - </div> - {% endif %} - </div> -{% else %} - <div class="box_item_model"> - <h3 class="title">{% trans "GGZ results for" %} {{ ggzauth.user.username }}</h3> - <div class="info_line show_center"> - <br /> - <b class="errormessage">User does not exist or has no ggz account - <br /> - <br /> - </table> - </div> -{% endif %} - -{% endblock %} === modified file 'templates/wlprofile/view_profile.html' --- templates/wlprofile/view_profile.html 2016-03-02 21:02:38 +0000 +++ templates/wlprofile/view_profile.html 2016-07-31 12:32:05 +0000 @@ -80,13 +80,5 @@ {% endifequal %} </table> </div> -{% comment %} -<table class="bottom_line" width="100%"> - <tr> - <td> - <a href="{% url 'wlggz_userstats' profile.user %}">View GGZ Statistics of this user</a> - </td> - </tr> -</table> -{% endcomment %} + {% endblock %} === removed file 'wlggz/fields.py' --- wlggz/fields.py 2013-06-14 19:23:53 +0000 +++ wlggz/fields.py 1970-01-01 00:00:00 +0000 @@ -1,81 +0,0 @@ -""" -Details about AutoOneToOneField: - http://softwaremaniacs.org/blog/2007/03/07/auto-one-to-one-field/ -""" - -from StringIO import StringIO -import logging - -from django.db.models import OneToOneField -from django.db.models.fields.related import SingleRelatedObjectDescriptor -from django.db import models -from django.core.files.uploadedfile import SimpleUploadedFile - - -class AutoSingleRelatedObjectDescriptor(SingleRelatedObjectDescriptor): - def __get__(self, instance, instance_type=None): - try: - return super(AutoSingleRelatedObjectDescriptor, self).__get__(instance, instance_type) - except self.related.model.DoesNotExist: - obj = self.related.model(**{self.related.field.name: instance}) - obj.save() - return obj - - -class AutoOneToOneField(OneToOneField): - """ - OneToOneField creates dependent object on first request from parent object - if dependent oject has not created yet. - """ - - def contribute_to_related_class(self, cls, related): - setattr(cls, related.get_accessor_name(), AutoSingleRelatedObjectDescriptor(related)) - #if not cls._meta.one_to_one_field: - #cls._meta.one_to_one_field = self - - -class ExtendedImageField(models.ImageField): - """ - Extended ImageField that can resize image before saving it. - """ - def __init__(self, *args, **kwargs): - self.width = kwargs.pop('width', None) - self.height = kwargs.pop('height', None) - super(ExtendedImageField, self).__init__(*args, **kwargs) - - - def save_form_data(self, instance, data): - if data and self.width and self.height: - if instance.avatar: - instance.avatar.delete() - - content = self.resize_image(data.read(), width=self.width, height=self.height) - data = SimpleUploadedFile(instance.user.username + ".png", content, data.content_type) - super(ExtendedImageField, self).save_form_data(instance, data) - - - def resize_image(self, rawdata, width, height): - """ - Resize image to fit it into (width, height) box. - """ - import Image - - image = Image.open(StringIO(rawdata)) - try: - oldw, oldh = image.size - - if oldw > width or oldh > height: - if oldw >= oldh: - x = int(round((oldw - oldh) / 2.0)) - image = image.crop((x, 0, (x + oldh) - 1, oldh - 1)) - else: - y = int(round((oldh - oldw) / 2.0)) - image = image.crop((0, y, oldw - 1, (y + oldw) - 1)) - image = image.resize((width, height), resample=Image.ANTIALIAS) - except Exception, err: - logging.error(err) - return '' - - string = StringIO() - image.save(string, format='PNG') - return string.getvalue() === modified file 'wlggz/forms.py' --- wlggz/forms.py 2013-06-13 18:59:49 +0000 +++ wlggz/forms.py 2016-07-31 12:32:05 +0000 @@ -12,8 +12,6 @@ import hashlib import base64 -import settings -import re class EditGGZForm(forms.ModelForm): password = forms.CharField(label=_(u'Online Gaming Password'), widget = forms.PasswordInput(render_value = False), required=True) === removed file 'wlggz/ggz_models.py' --- wlggz/ggz_models.py 2011-10-08 18:47:56 +0000 +++ wlggz/ggz_models.py 1970-01-01 00:00:00 +0000 @@ -1,186 +0,0 @@ -#!/usr/bin/env python -tt -# encoding: utf-8 -# -# Created by Timo Wingender <timo.wingen...@gmx.de> on 2010-06-03. -# -# Last Modified: $Date$ -# - - -# This is an auto-generated and eddited representation for the ggzd tables. -# - -from django.db import models -from django.db.models import OneToOneField, ForeignKey -from django.contrib.auth.models import User -from django.core.urlresolvers import reverse -from django.utils.safestring import mark_safe - -import datetime - -def ggz_userlink(user): - data = u'<a href="%s">%s</a>' % (\ - reverse('wlggz_userstats', args=[user.username]), user.username) - return mark_safe(data) - -class GGZMatches(models.Model): - id = models.IntegerField(primary_key=True) - date = models.IntegerField() - game = models.TextField() - winner_user = ForeignKey(User, to_field='username', db_column='winner', related_name='wlggz_matchwins') - savegame = models.TextField(blank=True) - - def winner_as_userlink(self): - try: - return ggz_userlink(self.winner_user) - except: - if len(self.winner) > 0: - return "%s[Guest]" % (self.winner) - return "" - - class Meta: - db_table = u'wlggz_matches' - - def date_date(self): - return datetime.datetime.fromtimestamp(self.date) - -class GGZMatchplayers(models.Model): - id = models.IntegerField(primary_key=True) - match = ForeignKey(GGZMatches, to_field='id', db_column='match', related_name='wlggz_matchplayers') - handle_user = ForeignKey(User, to_field='username', db_column='handle', related_name='wlggz_matches') - playertype = models.CharField(max_length=768) - result = models.CharField(max_length=10) - points = models.IntegerField() - team = models.IntegerField() - - def handle_as_userlink(self): - try: - return ggz_userlink(self.handle_user) - except: - return "%s[Guest]" % (self.handle) - - class Meta: - db_table = u'wlggz_matchplayers' - -class GGZPermissions(models.Model): - handle = models.CharField(max_length=768, blank=True) - join_table = models.IntegerField(null=True, blank=True) - launch_table = models.IntegerField(null=True, blank=True) - rooms_login = models.IntegerField(null=True, blank=True) - rooms_admin = models.IntegerField(null=True, blank=True) - chat_announce = models.IntegerField(null=True, blank=True) - chat_bot = models.IntegerField(null=True, blank=True) - no_stats = models.IntegerField(null=True, blank=True) - edit_tables = models.IntegerField(null=True, blank=True) - table_privmsg = models.IntegerField(null=True, blank=True) - class Meta: - db_table = u'wlggz_permissions' - - -#class Savegameplayers(models.Model): -# id = models.IntegerField(primary_key=True) -# tableid = models.IntegerField() -# stamp = models.IntegerField() -# seat = models.IntegerField() -# handle = models.CharField(max_length=768, blank=True) -# seattype = models.CharField(max_length=768) -# class Meta: -# db_table = u'savegameplayers' - -#class Savegames(models.Model): -# id = models.IntegerField(primary_key=True) -# date = models.IntegerField() -# game = models.CharField(max_length=768) -# owner = models.CharField(max_length=768) -# savegame = models.CharField(max_length=768) -# tableid = models.IntegerField() -# stamp = models.IntegerField() -# class Meta: -# db_table = u'savegames' - -class GGZStats(models.Model): - id = models.IntegerField(primary_key=True) - handle_user = OneToOneField(User, to_field='username', related_name='wlggzstats', db_column='handle') - game = models.TextField() - wins = models.IntegerField() - losses = models.IntegerField() - ties = models.IntegerField() - forfeits = models.IntegerField() - rating = models.FloatField() - ranking = models.IntegerField() - highscore = models.IntegerField() - - def handle_as_userlink(): - try: - return ggz_userlink(self.handle_user) - except: - return "%s[Guest]" % (self.handle) - - class Meta: - db_table = u'wlggz_stats' - -#class GGZTeammembers(models.Model): -# id = models.IntegerField(primary_key=True) -# teamname = models.TextField() -# username = models.TextField() -# role = models.TextField() -# entrydate = models.IntegerField() -# class Meta: -# db_table = u'ggz_db.teammembers' - -#class Teams(models.Model): -# id = models.IntegerField(primary_key=True) -# teamname = models.TextField() -# fullname = models.TextField() -# icon = models.TextField() -# foundingdate = models.IntegerField() -# founder = models.TextField() -# homepage = models.TextField() -# class Meta: -# db_table = u'ggz_db.teams' - -#class Tournamentplayers(models.Model): -# id = models.IntegerField(primary_key=True) -# tid = models.IntegerField() -# number = models.IntegerField() -# name = models.TextField() -# playertype = models.TextField() -# class Meta: -# db_table = u'tournamentplayers' - -#class Tournaments(models.Model): -# id = models.IntegerField(primary_key=True) -# name = models.TextField() -# game = models.TextField() -# date = models.IntegerField() -# organizer = models.TextField() -# class Meta: -# db_table = u'tournaments' - -#class Userinfo(models.Model): -# id = models.IntegerField(primary_key=True) -# handle = models.CharField(max_length=768) -# photo = models.TextField() -# gender = models.TextField() -# country = models.TextField() -# pubkey = models.TextField() -# blogfeed = models.TextField() -# longitude = models.FloatField() -# latitude = models.FloatField() -# alterpass = models.TextField() -# class Meta: -# db_table = u'userinfo' - -#class Users(models.Model): -# id = models.IntegerField() -# handle = models.CharField(max_length=90) -# password = models.CharField(max_length=240, blank=True) -# name = models.CharField(max_length=183) -# email = models.CharField(max_length=225) -# firstlogin = models.DateTimeField() -# lastlogin = models.DateTimeField(null=True, blank=True) -# permissions = models.IntegerField(null=True, blank=True) -# confirmed = models.IntegerField(null=True, blank=True) -# class Meta: -# db_table = u'users' - === modified file 'wlggz/urls.py' --- wlggz/urls.py 2016-06-04 14:17:40 +0000 +++ wlggz/urls.py 2016-07-31 12:32:05 +0000 @@ -13,13 +13,6 @@ import views urlpatterns = [ - url(r'^$', views.view_overview, name='wlggz_main'), - url(r'^stats/?$', views.view, name='wlggz_userstats'), - url(r'^info/?$', views.view, name='wlggz_userinfo'), - url(r'^stats/(?P<user>.*)', views.view, name='wlggz_userstats'), - url(r'^info/(?P<user>.*)', views.view, name='wlggz_userinfo'), url(r'^changepw$', views.change_password, name='wlggz_changepw'), - url(r'^ranking$', views.view_ranking, name='wlggz_ranking'), - url(r'^matches$', views.view_matches, name='wlggz_matches'), ] === modified file 'wlggz/views.py' --- wlggz/views.py 2013-06-13 18:59:49 +0000 +++ wlggz/views.py 2016-07-31 12:32:05 +0000 @@ -3,93 +3,12 @@ from django.core.urlresolvers import reverse from django.contrib.auth.decorators import login_required -from django.contrib.auth.models import User from django.shortcuts import render_to_response from django.template import RequestContext from django.http import HttpResponseRedirect -from django.db import models - from forms import EditGGZForm -import settings -import ggz_models - -def view_overview(request): - return render_to_response("wlggz/view_ggz_overview.html", - context_instance=RequestContext(request)) - -def view_matches(request): - - try: - matches = ggz_models.GGZMatches.objects.order_by('-date')[:10] - except ggz_models.GGZMatches.DoesNotExist: - matches = None - - template_params = { - "ggzmatches": matches, - } - - return render_to_response("wlggz/view_ggz_matches.html", - template_params, - context_instance=RequestContext(request)) - -# Settings -@login_required -def view(request, user = None): - """ - empty text - """ - - template_params = {} - - try: - if user is None: - u = request.user - else: - u = User.objects.get( username = user ) - - template_params["profile"] = u.wlprofile - except User.DoesNotExist: - u = None - - if u: - try: - template_params["ggzauth"] = u.wlggz - except ggz_models.GGZauth.DoesNotExist: - pass - try: - wlggzstats = u.wlggzstats - matches = u.wlggz_matches.order_by('-id')[:10] - wonmatches = u.wlggz_matchwins.order_by('-id')[:10] - template_params["ggzstats"] = wlggzstats - template_params["ggzmatches"] = matches - template_params["ggzwonmatches"] = wonmatches - except (ggz_models.GGZStats.DoesNotExist): - pass - - return render_to_response("wlggz/view_ggz_playerstats.html", - template_params, - context_instance=RequestContext(request)) - -def view_ranking(request): - """ - empty text - """ - - try: - stats = ggz_models.GGZStats.objects.order_by('-rating')[:10] - except (ggz_models.GGZStats.DoesNotExist): - stats = None - - template_params = { - "ggzstats": stats, - } - - return render_to_response("wlggz/view_ggz_highscore.html", - template_params, - context_instance=RequestContext(request)) - @login_required def change_password(request): """ === modified file 'wlprofile/models.py' --- wlprofile/models.py 2016-05-01 12:00:35 +0000 +++ wlprofile/models.py 2016-07-31 12:32:05 +0000 @@ -73,8 +73,4 @@ else: return { "text":"One Elder of Players", "image":"rang_7.png" } - def get_ggzstats(self): - try: - return self.user.wlggzstats - except: - return None + === modified file 'wlprofile/templatetags/wlprofile_extras.py' --- wlprofile/templatetags/wlprofile_extras.py 2016-03-02 21:02:38 +0000 +++ wlprofile/templatetags/wlprofile_extras.py 2016-07-31 12:32:05 +0000 @@ -21,11 +21,6 @@ reverse('profile_view', args=[user.username]), user.username) return mark_safe(data) -@register.filter -def user_link_ggz(user): - data = u'<a href="%s">%s</a>' % (\ - reverse('wlggz_userstats', args=[user.username]), user.username) - return mark_safe(data)
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp