21
21
from registration.backends.default import DefaultBackend
23
24
def register(request):
25
Overwritten view from registration to include a captcha.
26
We only need this because the remote IP addr must be passed
27
to the form; the registration doesn't do this
25
"""Overwritten view from registration to include a captcha.
27
We only need this because the remote IP addr must be passed to the
28
form; the registration doesn't do this
29
31
remote_ip = request.META['REMOTE_ADDR']
30
32
if request.method == 'POST':
31
form = RegistrationWithCaptchaForm(remote_ip,data=request.POST,
33
form = RegistrationWithCaptchaForm(remote_ip, data=request.POST,
33
35
if form.is_valid():
34
36
new_user = DefaultBackend().register(request, **form.cleaned_data)
35
37
return HttpResponseRedirect(reverse('registration_complete'))
37
39
form = RegistrationWithCaptchaForm(remote_ip)
39
return render_to_response("registration/registration_form.html",
40
{ 'registration_form': form },
41
return render_to_response('registration/registration_form.html',
42
{'registration_form': form},
41
43
context_instance=RequestContext(request))
43
46
def developers(request):
45
This reads out some json files in the SVN directory, and returns it
46
as a wl_markdown_object. This replaces the wiki developers list
49
# Get locale and translator names from each .json file and
47
"""This reads out some json files in the SVN directory, and returns it as a
50
This replaces the wiki developers list
54
# Get locale and translator names from each .json file and
50
55
# store them in one list.
54
path = os.path.normpath(WIDELANDS_SVN_DIR + "txts/translators/")
59
path = os.path.normpath(WIDELANDS_SVN_DIR + 'i18n/locales/')
56
61
transl_files = os.listdir(path)
58
63
for fname in transl_files:
59
if fname.endswith(".json"):
60
with open(path + "/" + fname,"r") as f:
61
json_data = json.load(f)["locale-translators"]
63
if json_data["translator-list"] != "translator-credits":
64
if fname.endswith('.json'):
65
with open(path + '/' + fname, 'r') as f:
66
json_data = json.load(f)
68
if json_data['translator-list'] != 'translator-credits':
69
if not 'your-language-name-in-english' in json_data:
70
transl_list = ['KeyError']
64
72
transl_list.append(json_data)
74
transl_list = ['KeyError']
77
# No KeyError -> Sort the list
78
if 'KeyError' in transl_list:
79
txt = 'Some Translator key is wrong, please contact the Developers.\n'
81
transl_list.sort(key=itemgetter(
82
'your-language-name-in-english'))
66
txt = "No files for translators found!"
85
txt = 'No files for translators found!\n'
68
txt = txt + "Couldn't find translators directory!"
87
txt = txt + "Couldn't find translators directory!\n"
71
89
# Get other developers, put in the translators list
72
# at given position and prepaire all for wl_markdown
90
# at given position and prepare all for wl_markdown
74
f = open(WIDELANDS_SVN_DIR + "txts/developers.json", "r")
75
json_data = json.load(f)["developers"]
92
with open(WIDELANDS_SVN_DIR + 'txts/developers.json', 'r') as f:
93
json_data = json.load(f)['developers']
78
95
for head in json_data:
80
txt = txt + "##" + head["heading"] + "\n"
81
# Inserting Translators
82
if head["heading"] == "Translators":
97
txt = txt + '##' + head['heading'] + '\n'
98
# Inserting Translators if there was no error
99
if head['heading'] == 'Translators' and 'KeyError' not in transl_list:
83
100
for values in (transl_list):
84
101
# Add subheader for locale
85
txt = txt + "### " + values["your-language-name"] + "\n"
102
txt = txt + '### ' + \
103
values['your-language-name-in-english'] + '\n'
86
104
# Prepaire the names for wl_markdown
87
txt = txt + "* " + values["translator-list"].replace('\n', '\n* ') + "\n"
106
values['translator-list'].replace('\n', '\n* ') + '\n'
89
108
# Add a subheader or/and the member(s)
90
for entry in head["entries"]:
91
if "subheading" in entry.keys():
92
txt = txt + "###" + entry["subheading"] + "\n"
93
if "members" in entry.keys():
94
for name in entry["members"]:
95
txt = txt + "* " + name + "\n"
109
for entry in head['entries']:
110
if 'subheading' in entry.keys():
111
txt = txt + '###' + entry['subheading'] + '\n'
112
if 'members' in entry.keys():
113
for name in entry['members']:
114
txt = txt + '* ' + name + '\n'
97
116
txt = txt + "Couldn't find developer file!"
99
txt = do_wl_markdown(txt,custom=False)
101
return render_to_response("mainpage/developers.html",
118
txt = do_wl_markdown(txt, custom=False)
120
return render_to_response('mainpage/developers.html',
103
122
context_instance=RequestContext(request)
108
126
def changelog(request):
110
This reads out the changelog in the SVN directory, and returns it
111
as a wl_markdown_object. This replaces the wiki changelog
113
data = open(WIDELANDS_SVN_DIR + "ChangeLog", "r").read()
114
return render_to_response("mainpage/changelog.html",
127
"""This reads out the changelog in the SVN directory, and returns it as a
130
This replaces the wiki changelog
133
data = open(WIDELANDS_SVN_DIR + 'ChangeLog', 'r').read()
134
return render_to_response('mainpage/changelog.html',
116
136
context_instance=RequestContext(request)