-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
translate_url templatetag is added, changes were made to make code co…
…mpatible with it
- Loading branch information
Showing
8 changed files
with
29 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django import template | ||
from django.urls import resolve, reverse | ||
from django.utils import translation | ||
|
||
register = template.Library() | ||
|
||
@register.simple_tag(takes_context=True) | ||
def translate_url(context, language): | ||
''' | ||
used to translate urls for switching languages | ||
''' | ||
view = resolve(context['request'].path) | ||
request_language = translation.get_language() | ||
translation.activate(language) | ||
url = reverse(view.url_name, args=view.args, kwargs=view.kwargs) | ||
translation.activate(request_language) | ||
return url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,91 +56,5 @@ def test_get(self): | |
self.assertEqual(response.context['erhebungswoche'], self.orig_contents) | ||
except AttributeError: | ||
pass | ||
|
||
def test_post(self): | ||
self.client.login(username='supers', password='pw') | ||
s, v = get_veranstaltung('v') | ||
p0 = Person.objects.create(vorname='Je', nachname='Mand', email='[email protected]', geschlecht='w', | ||
anschrift='S202 D120') | ||
p1 = Person.objects.create(vorname='Noch Je', nachname='Mand', email='[email protected]', geschlecht='m') | ||
v.veranstalter.add(p0) | ||
v.veranstalter.add(p1) | ||
v.verantwortlich = p0 | ||
|
||
# kein Semester angegeben | ||
response = self.client.post(self.path, **{'REMOTE_USER': 'super'}) | ||
self.assertEqual(response.status_code, 302) | ||
self.assertTrue(response['Location'].endswith('/intern/generate_letters/')) | ||
|
||
# kein Abgabedatum angegeben | ||
response = self.client.post(self.path, {'semester': s.semester}, **{'REMOTE_USER': 'super'}) | ||
self.assertEqual(response.status_code, 302) | ||
self.assertTrue(response['Location'].endswith('/intern/generate_letters/')) | ||
|
||
# keine zu evaluierenden Veranstaltungen | ||
ad = '10. - 11. November 2011' | ||
|
||
response = self.client.post(self.path, | ||
{'semester': s.semester, 'erhebungswoche': ad}, **{'REMOTE_USER': 'super'}) | ||
self.assertEqual(response.status_code, 302) | ||
self.assertTrue(response['Location'].endswith('/intern/generate_letters/')) | ||
|
||
# alles OK | ||
v.anzahl = 42 | ||
v.sprache = 'en' | ||
v.save() | ||
|
||
self._delete_erhebungswoche_file() | ||
|
||
response = self.client.post(self.path, | ||
{'semester': s.semester, 'erhebungswoche': '10. - 11. November 2011', | ||
'vorlage': 'Anschreiben'}, **{'REMOTE_USER': 'super'}) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertRegex(response['Content-Disposition'], | ||
r'^attachment; filename=[a-zA-Z0-9_-]+\.pdf$') | ||
self.assertEqual(ad, self._get_erhebungswoche()) | ||
with open(settings.LATEX_PATH + 'veranstalter.adr', 'r') as f: | ||
self.assertEqual(f.readline().strip(), | ||
'\\adrentry{Je Mand}{S202 D120}{Stoning I}{42}{en}{Vorlesung}{2000000001005}{}{}') | ||
|
||
# test Aufkleber | ||
response = self.client.post(self.path, | ||
{'semester': s.semester, 'erhebungswoche': '10. - 11. November 2011', | ||
'vorlage': 'Aufkleber'}, **{'REMOTE_USER': 'super'}) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertRegex(response['Content-Disposition'], | ||
r'^attachment; filename=[a-zA-Z0-9_-]+\.pdf$') | ||
self.assertEqual(ad, self._get_erhebungswoche()) | ||
with open(settings.LATEX_PATH + '../aufkleber/' + 'veranstalter.adr', 'r') as f: | ||
self.assertEqual(f.readline().strip(), | ||
'\\adrentry{Je Mand}{S202 D120}{Stoning I}{42}{en}{Vorlesung}{2000000001005}{}{}') | ||
|
||
with self.settings(TEST_LATEX_ERROR=True): | ||
response = self.client.post(self.path, | ||
{'semester': s.semester, 'erhebungswoche': '10. - 11. November 2011', | ||
'vorlage': 'Anschreiben'}, **{'REMOTE_USER': 'super'}) | ||
self.assertEqual(response.templates[0].name, 'intern/generate_letters.html') | ||
|
||
# test Aufkleber with variable number | ||
response = self.client.post(self.path, | ||
{'semester': s.semester, 'erhebungswoche': '10. - 11. November 2011', | ||
'vorlage': 'Aufkleber', 'anzahlaufkleber':'85'}, **{'REMOTE_USER': 'super'}) | ||
self.assertEqual(response.status_code, 302) | ||
v.anzahl = 86 | ||
v.save() | ||
response = self.client.post(self.path, | ||
{'semester': s.semester, 'erhebungswoche': '10. - 11. November 2011', | ||
'vorlage': 'Aufkleber', 'anzahlaufkleber': '85'}, **{'REMOTE_USER': 'super'}) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertRegex(response['Content-Disposition'], | ||
r'^attachment; filename=[a-zA-Z0-9_-]+\.pdf$') | ||
self.assertEqual(ad, self._get_erhebungswoche()) | ||
with open(settings.LATEX_PATH + '../aufkleber/' + 'veranstalter.adr', 'r') as f: | ||
self.assertEqual(f.readline().strip(), | ||
'\\adrentry{Je Mand}{S202 D120}{Stoning I}{86}{en}{Vorlesung}{2000000001005}{}{}') | ||
|
||
with self.settings(TEST_LATEX_ERROR=True): | ||
response = self.client.post(self.path, | ||
{'semester': s.semester, 'erhebungswoche': '10. - 11. November 2011', | ||
'vorlage': 'Anschreiben'}, **{'REMOTE_USER': 'super'}) | ||
self.assertEqual(response.templates[0].name, 'intern/generate_letters.html') | ||
|
||
## test_post is deleted as latex no longer in use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file renamed
BIN
+337 Bytes
src/locale/de_DE/LC_MESSAGES/django.mo → src/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,15 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-10-25 00:27+0200\n" | ||
"POT-Creation-Date: 2024-11-09 18:09+0100\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
#: feedback/models/base.py:190 feedback/models/base.py:308 | ||
#: feedback/models/base.py:723 | ||
msgid "first name" | ||
|
Binary file renamed
BIN
+337 Bytes
src/locale/en_US/LC_MESSAGES/django.mo → src/locale/en/LC_MESSAGES/django.mo
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,15 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-10-25 00:27+0200\n" | ||
"POT-Creation-Date: 2024-11-09 18:09+0100\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
"Language: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
#: feedback/models/base.py:190 feedback/models/base.py:308 | ||
#: feedback/models/base.py:723 | ||
msgid "first name" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters