Added a view to the about menu to read the LICENSE file included with Mayan

This commit is contained in:
Roberto Rosario
2011-08-14 23:31:12 -04:00
parent 094a4125dc
commit aba9d47ad8
4 changed files with 47 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ from django.contrib.auth import models as auth_models
from django.contrib.auth.management import create_superuser from django.contrib.auth.management import create_superuser
from django.db.models import signals 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.conf import settings as common_settings
from common.utils import validate_path 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') 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'} about_view = {'text': _('about'), 'view': 'about_view', 'famfam': 'information'}
changelog = {'text': _('changelog'), 'view': 'changelog', 'famfam': 'book_open'} 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: if common_settings.AUTO_CREATE_ADMIN:

View File

@@ -149,19 +149,27 @@ class EmailAuthenticationForm(AuthenticationForm):
EmailAuthenticationForm.base_fields.keyOrder = ['email', 'password'] EmailAuthenticationForm.base_fields.keyOrder = ['email', 'password']
class ChangelogForm(forms.Form): class FileDisplayForm(forms.Form):
text = forms.CharField( text = forms.CharField(
label=_(u'Text'), label='',#_(u'Text'),
widget=forms.widgets.Textarea( widget=forms.widgets.Textarea(
attrs={'cols': 40, 'rows': 20, 'readonly': 'readonly'} attrs={'cols': 40, 'rows': 20, 'readonly': 'readonly'}
) )
) )
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ChangelogForm, self).__init__(*args, **kwargs) super(FileDisplayForm, self).__init__(*args, **kwargs)
CHANGELOG_FILENAME = u'Changelog.txt' changelog_path = os.path.join(settings.PROJECT_ROOT, self.DIRECTORY, self.FILENAME)
CHANGELOG_DIRECTORY = u'docs'
changelog_path = os.path.join(settings.PROJECT_ROOT, CHANGELOG_DIRECTORY, CHANGELOG_FILENAME)
fd = open(changelog_path) fd = open(changelog_path)
self.fields['text'].initial = fd.read() self.fields['text'].initial = fd.read()
fd.close() fd.close()
class ChangelogForm(FileDisplayForm):
FILENAME = u'Changelog.txt'
DIRECTORY = u'docs'
class LicenseForm(FileDisplayForm):
FILENAME = u'LICENSE'
DIRECTORY = u'docs'

View File

@@ -3,9 +3,9 @@ from django.views.generic.simple import direct_to_template
from django.conf import settings from django.conf import settings
urlpatterns = patterns('common.views', urlpatterns = patterns('common.views',
url(r'^about/$', direct_to_template, {'template': 'about.html'}, 'about'), url(r'^about/$', direct_to_template, {'template': 'about.html'}, 'about_view'),
url(r'^changelog/$', 'changelog', (), 'changelog'), url(r'^changelog/$', 'changelog_view', (), 'changelog_view'),
#url(r'^password/change/done/$', 'django.contrib.auth.views.password_change_done', {'template_name': 'password_change_done.html'}), url(r'^license/$', 'license_view', (), 'license_view'),
url(r'^password/change/done/$', 'password_change_done', (), name='password_change_done'), 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'), url(r'^object/multiple/action/$', 'multi_object_action_view', (), name='multi_object_action_view'),

View File

@@ -9,7 +9,8 @@ from django.core.urlresolvers import reverse
from django.utils.http import urlencode from django.utils.http import urlencode
from django.contrib.auth.views import login 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.forms import EmailAuthenticationForm
from common.conf.settings import LOGIN_METHOD from common.conf.settings import LOGIN_METHOD
@@ -173,6 +174,10 @@ def current_user_edit(request):
def login_view(request): def login_view(request):
"""
Control how the use is to be authenticated, options are 'email' and
'username'
"""
kwargs = {'template_name': 'login.html'} kwargs = {'template_name': 'login.html'}
if LOGIN_METHOD == 'email': if LOGIN_METHOD == 'email':
@@ -181,7 +186,10 @@ def login_view(request):
return login(request, **kwargs) return login(request, **kwargs)
def changelog(request): def changelog_view(request):
"""
Display the included Changelog.txt file from the about menu
"""
form = ChangelogForm() form = ChangelogForm()
return render_to_response( return render_to_response(
'generic_detail.html', { 'generic_detail.html', {
@@ -189,3 +197,16 @@ def changelog(request):
'title': _(u'Changelog'), 'title': _(u'Changelog'),
}, },
context_instance=RequestContext(request)) 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))