diff --git a/apps/common/__init__.py b/apps/common/__init__.py index 9cd9e2afd7..6c9e4b6287 100644 --- a/apps/common/__init__.py +++ b/apps/common/__init__.py @@ -5,7 +5,7 @@ from django.contrib.auth import models as auth_models from django.contrib.auth.management import create_superuser from django.db.models import signals -from navigation.api import register_links +from navigation.api import register_links, register_top_menu from common.conf import settings as common_settings from common.utils import validate_path @@ -20,10 +20,13 @@ current_user_edit = {'text': _(u'edit details'), 'view': 'current_user_edit', 'f register_links(['current_user_details', 'current_user_edit', 'password_change_view'], [current_user_details, current_user_edit, password_change_view], menu_name='secondary_menu') -about = {'text': _('about'), 'view': 'about', 'famfam': 'information'} -changelog = {'text': _('changelog'), 'view': 'changelog', 'famfam': 'book_open'} +about_view = {'text': _('about'), 'view': 'about_view', 'famfam': 'information'} +changelog_view = {'text': _('changelog'), 'view': 'changelog_view', 'famfam': 'book_open'} +license_view = {'text': _('license'), 'view': 'license_view', 'famfam': 'script'} -register_links(['about', 'changelog'], [about, changelog], menu_name='secondary_menu') +register_links(['about_view', 'changelog_view', 'license_view'], [about_view, changelog_view, license_view], menu_name='secondary_menu') + +register_top_menu('about', link={'text': _(u'about'), 'view': 'about_view', 'famfam': 'information'}, position=-1) if common_settings.AUTO_CREATE_ADMIN: diff --git a/apps/common/forms.py b/apps/common/forms.py index 7c0c32ad60..21626bb1ea 100644 --- a/apps/common/forms.py +++ b/apps/common/forms.py @@ -149,19 +149,27 @@ class EmailAuthenticationForm(AuthenticationForm): EmailAuthenticationForm.base_fields.keyOrder = ['email', 'password'] -class ChangelogForm(forms.Form): +class FileDisplayForm(forms.Form): text = forms.CharField( - label=_(u'Text'), + label='',#_(u'Text'), widget=forms.widgets.Textarea( attrs={'cols': 40, 'rows': 20, 'readonly': 'readonly'} ) ) def __init__(self, *args, **kwargs): - super(ChangelogForm, self).__init__(*args, **kwargs) - CHANGELOG_FILENAME = u'Changelog.txt' - CHANGELOG_DIRECTORY = u'docs' - changelog_path = os.path.join(settings.PROJECT_ROOT, CHANGELOG_DIRECTORY, CHANGELOG_FILENAME) + super(FileDisplayForm, self).__init__(*args, **kwargs) + changelog_path = os.path.join(settings.PROJECT_ROOT, self.DIRECTORY, self.FILENAME) fd = open(changelog_path) self.fields['text'].initial = fd.read() fd.close() + + +class ChangelogForm(FileDisplayForm): + FILENAME = u'Changelog.txt' + DIRECTORY = u'docs' + + +class LicenseForm(FileDisplayForm): + FILENAME = u'LICENSE' + DIRECTORY = u'docs' diff --git a/apps/common/urls.py b/apps/common/urls.py index 851f9cd507..8ac491fbd5 100644 --- a/apps/common/urls.py +++ b/apps/common/urls.py @@ -3,9 +3,9 @@ from django.views.generic.simple import direct_to_template from django.conf import settings urlpatterns = patterns('common.views', - url(r'^about/$', direct_to_template, {'template': 'about.html'}, 'about'), - url(r'^changelog/$', 'changelog', (), 'changelog'), - #url(r'^password/change/done/$', 'django.contrib.auth.views.password_change_done', {'template_name': 'password_change_done.html'}), + url(r'^about/$', direct_to_template, {'template': 'about.html'}, 'about_view'), + url(r'^changelog/$', 'changelog_view', (), 'changelog_view'), + url(r'^license/$', 'license_view', (), 'license_view'), url(r'^password/change/done/$', 'password_change_done', (), name='password_change_done'), url(r'^object/multiple/action/$', 'multi_object_action_view', (), name='multi_object_action_view'), diff --git a/apps/common/views.py b/apps/common/views.py index 6662342c15..48c2570bb5 100644 --- a/apps/common/views.py +++ b/apps/common/views.py @@ -9,7 +9,8 @@ from django.core.urlresolvers import reverse from django.utils.http import urlencode from django.contrib.auth.views import login -from common.forms import ChoiceForm, UserForm, UserForm_view, ChangelogForm +from common.forms import ChoiceForm, UserForm, UserForm_view, \ + ChangelogForm, LicenseForm from common.forms import EmailAuthenticationForm from common.conf.settings import LOGIN_METHOD @@ -173,6 +174,10 @@ def current_user_edit(request): def login_view(request): + """ + Control how the use is to be authenticated, options are 'email' and + 'username' + """ kwargs = {'template_name': 'login.html'} if LOGIN_METHOD == 'email': @@ -181,7 +186,10 @@ def login_view(request): return login(request, **kwargs) -def changelog(request): +def changelog_view(request): + """ + Display the included Changelog.txt file from the about menu + """ form = ChangelogForm() return render_to_response( 'generic_detail.html', { @@ -189,3 +197,16 @@ def changelog(request): 'title': _(u'Changelog'), }, context_instance=RequestContext(request)) + + +def license_view(request): + """ + Display the included LICENSE file from the about menu + """ + form = LicenseForm() + return render_to_response( + 'generic_detail.html', { + 'form': form, + 'title': _(u'License'), + }, + context_instance=RequestContext(request))