From 91bd6eed062774cff93e4ffca0bdfcda2b4b0899 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 17 Oct 2005 18:08:55 +0000 Subject: [PATCH 01/13] Fixed typo in docs/templates.txt git-svn-id: http://code.djangoproject.com/svn/django/trunk@911 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/templates.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/templates.txt b/docs/templates.txt index 215b663634..5c52371c8a 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -399,13 +399,13 @@ Built-in tag reference block are output:: {% if athlete_list %} - Number of athletes: {{ athlete_list|count }} + Number of athletes: {{ athlete_list|length }} {% else %} No athletes. {% endif %} In the above, if ``athlete_list`` is not empty, the number of athletes will be - displayed by the ``{{ athlete_list|count }}`` variable. + displayed by the ``{{ athlete_list|length }}`` variable. As you can see, the ``if`` tag can take an option ``{% else %}`` clause that will be displayed if the test fails. @@ -432,8 +432,8 @@ Built-in tag reference {% if athlete_list %} {% if coach_list %} - Number of athletes: {{ athlete_list|count }}. - Number of coaches: {{ coach_list|count }}. + Number of athletes: {{ athlete_list|length }}. + Number of coaches: {{ coach_list|length }}. {% endif %} {% endif %} From 72442152d231ec5cb0ce07b3a6a7aa6d2a350525 Mon Sep 17 00:00:00 2001 From: Wilson Miner Date: Mon, 17 Oct 2005 20:22:12 +0000 Subject: [PATCH 02/13] Fixed #638 and cleaned up some CSS git-svn-id: http://code.djangoproject.com/svn/django/trunk@917 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/conf/admin_media/css/changelists.css | 82 +++++++++------------ django/conf/admin_media/css/global.css | 69 +---------------- 2 files changed, 36 insertions(+), 115 deletions(-) diff --git a/django/conf/admin_media/css/changelists.css b/django/conf/admin_media/css/changelists.css index 966ca4a486..7ff59c5e6b 100644 --- a/django/conf/admin_media/css/changelists.css +++ b/django/conf/admin_media/css/changelists.css @@ -1,60 +1,44 @@ -/* - ______________________________ - DJANGO - Admin Changelist Styles - - Extends base.css - - by Wilson Miner - wilson@lawrence.com - - Copyright (c) 2005 - Lawrence Journal-World - - 645 New Hampshire - Lawrence, KS 66044 - +/* + DJANGO Admin Changelist Styles + by Wilson Miner wilson@lawrence.com + Copyright (c) 2005 Lawrence Journal-World */ -#changelist {position:relative; width:100%;} -#changelist table {width:100%;} -.change-list .filtered table { border-right:1px solid #ddd, width:100%; } -.change-list .filtered {min-height:400px; _height:400px;} -.change-list .filtered {background:white url(../img/admin/changelist-bg.gif) top right repeat-y !important;} -.change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull {margin-right:160px !important; width:auto !important; } -.change-list .filtered table tbody th {padding-right:10px;} -#changelist .toplinks {border-bottom:1px solid #ccc !important;} -#changelist .paginator { color:#666; border-top:1px solid #eee; border-bottom:1px solid #eee; background:white url(../img/admin/nav-bg.gif) 0 180% repeat-x; overflow:hidden;} +#changelist { position:relative; width:100%; } +#changelist table { width:100%; } +.change-list .filtered table { border-right:1px solid #ddd; } +.change-list .filtered { min-height:400px; _height:400px; } +.change-list .filtered { background:white url(../img/admin/changelist-bg.gif) top right repeat-y !important; } +.change-list .filtered table, .change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull { margin-right:160px !important; width:auto !important; } +.change-list .filtered table tbody th { padding-right:10px; } +#changelist .toplinks { border-bottom:1px solid #ccc !important; } +#changelist .paginator { color:#666; border-top:1px solid #eee; border-bottom:1px solid #eee; background:white url(../img/admin/nav-bg.gif) 0 180% repeat-x; overflow:hidden; } .change-list .filtered .paginator { border-right:1px solid #ddd; } /* CHANGELIST TABLES */ - -#changelist table thead th {white-space:nowrap;} -#changelist table tbody td {border-left: 1px solid #ddd;} -#changelist table tfoot {color: #666;} +#changelist table thead th { white-space:nowrap; } +#changelist table tbody td { border-left: 1px solid #ddd; } +#changelist table tfoot { color: #666; } /* TOOLBAR */ - -#changelist #toolbar {padding:3px; border-bottom:1px solid #ddd; background:#e1e1e1 url(../img/admin/nav-bg.gif) top left repeat-x; color:#666;} -#changelist #toolbar form input {font-size:11px; padding:1px 2px;} -#changelist #toolbar form #searchbar {padding:2px;} -#changelist #changelist-search img {vertical-align:middle;} +#changelist #toolbar { padding:3px; border-bottom:1px solid #ddd; background:#e1e1e1 url(../img/admin/nav-bg.gif) top left repeat-x; color:#666; } +#changelist #toolbar form input { font-size:11px; padding:1px 2px; } +#changelist #toolbar form #searchbar { padding:2px; } +#changelist #changelist-search img { vertical-align:middle; } /* FILTER COLUMN */ - -#changelist-filter {position:absolute; top:0; right:0; z-index:1000; width:160px; border-left:1px solid #ddd; background:#efefef; margin:0;} -#changelist-filter h2 {font-size:11px; padding:2px 5px; border-bottom:1px solid #ddd;} -#changelist-filter h3 {font-size:12px; margin-bottom:0;} -#changelist-filter ul {padding-left:0;margin-left:10px;_margin-right:-10px;} -#changelist-filter li {list-style-type:none; margin-left:0; padding-left:0;} -#changelist-filter a {color:#999;} -#changelist-filter a:hover {color:#036;} -#changelist-filter li.selected {border-left:5px solid #ccc; padding-left:5px;margin-left:-10px;} -#changelist-filter li.selected a {color:#5b80b2 !important;} +#changelist-filter { position:absolute; top:0; right:0; z-index:1000; width:160px; border-left:1px solid #ddd; background:#efefef; margin:0; } +#changelist-filter h2 { font-size:11px; padding:2px 5px; border-bottom:1px solid #ddd; } +#changelist-filter h3 { font-size:12px; margin-bottom:0; } +#changelist-filter ul { padding-left:0;margin-left:10px;_margin-right:-10px; } +#changelist-filter li { list-style-type:none; margin-left:0; padding-left:0; } +#changelist-filter a { color:#999; } +#changelist-filter a:hover { color:#036; } +#changelist-filter li.selected { border-left:5px solid #ccc; padding-left:5px;margin-left:-10px; } +#changelist-filter li.selected a { color:#5b80b2 !important; } /* DATE DRILLDOWN */ - -.change-list ul.toplinks {display:block; background:white url(../img/admin/nav-bg-reverse.gif) 0 -10px repeat-x; border-top:1px solid white; float:left; padding:0 !important; margin:0 !important; width:100%;} -.change-list ul.toplinks li {float: left; width: 9em; padding:3px 6px; font-weight: bold; list-style-type:none;} -.change-list ul.toplinks .date-back a {color:#999;} -.change-list ul.toplinks .date-back a:hover {color:#036;} +.change-list ul.toplinks { display:block; background:white url(../img/admin/nav-bg-reverse.gif) 0 -10px repeat-x; border-top:1px solid white; float:left; padding:0 !important; margin:0 !important; width:100%; } +.change-list ul.toplinks li { float: left; width: 9em; padding:3px 6px; font-weight: bold; list-style-type:none; } +.change-list ul.toplinks .date-back a { color:#999; } +.change-list ul.toplinks .date-back a:hover { color:#036; } diff --git a/django/conf/admin_media/css/global.css b/django/conf/admin_media/css/global.css index 7c60bf9755..453998c363 100644 --- a/django/conf/admin_media/css/global.css +++ b/django/conf/admin_media/css/global.css @@ -1,45 +1,17 @@ /* - ______________________________ - DJANGO - Admin Global Styles - - Extends base.css - - by Wilson Miner - wilson@lawrence.com - - Copyright (c) 2005 - Lawrence Journal-World - - 645 New Hampshire - Lawrence, KS 66044 - - ______________________________ - SITE DIMENSIONS - - Site Width: 768px - Content Width: 750px - Main Column: 580px - Sidebar: 220px - - ______________________________ - COLORS - - Blue #5b80b2 - Dark Blue #036 - + DJANGO Admin Global Styles + by Wilson Miner wilson@lawrence.com + Copyright (c) 2005 Lawrence Journal-World */ body { margin:0; padding:0; font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif; color:#333; } /* LINKS */ - a:link, a:visited { color: #5b80b2; text-decoration:none; } a:hover { color: #036; } a img { border:none; } /* GLOBAL DEFAULTS */ - p, ol, ul, dl { margin:.2em 0 .8em 0; font-size:12px; } p { padding:0; line-height:140%; } h1,h2,h3,h4,h5 { font-weight:bold; } @@ -67,7 +39,6 @@ div.system-message { background: #ffc; margin: 10px; padding: 6px 8px; font-size div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; color:red;background:#ffc url(../img/admin/icon_error.gif) 5px .3em no-repeat; } /* PAGE STRUCTURE */ - #container { position:relative; width:100%; min-width:720px; } #header { text-align:left; min-height:55px; _height:55px; } #content { margin:10px 15px; } @@ -76,13 +47,6 @@ div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; #footer { clear:both; padding:10px; } /* COLUMN TYPES */ -/* - colM = Main | M | - colMS = Main, Sidebar | M |S| - colSM = Sidebar, Main |S| M | - flex = single-column, liquid width - superwide = single-column, extra-wide fixed width -*/ .colMS, .colM, .colSM, .colM #content-main, .colM #content-main .xfull { width:758px; } /* master site width for fixed-width pages */ .colMS #content-main, .colSM #content-main, .colMS #content-main .xfull, .colSM #content-main .xfull { width:519px; } /* main column width for 2-column pages */ .colMS #content-related, .colSM #content-related, .colSMS #content-related { width:220px; } /* sidebar column width */ @@ -94,7 +58,6 @@ div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; .subcol { float:left; width:46%; margin-right:15px; } /* WIDTHS */ - .x50 { width:50px; } .x75 { width:75px; } .x100 { width:100px; } @@ -106,7 +69,6 @@ div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; .x500 { width:500px; } /* HEADER */ - #header { background:#417690; color:#ffc; } #header a:link, #header a:visited { color:white; } #header a:hover { text-decoration:underline; } @@ -117,12 +79,10 @@ div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; /* SIDEBAR */ - #content-related h3 { font-size:12px; color:#666; margin-bottom:3px; } #content-related h4 { font-size:11px; } /* TABLES */ - table { border-collapse:collapse; border-color:#ccc; } td, th { font-size:11px; line-height:13px; border-bottom:1px solid #eee; vertical-align:top; padding:5px; font-family:"Lucida Grande", Verdana, Arial, sans-serif; } th { text-align:left; font-size:12px; } @@ -141,7 +101,6 @@ table#change-history { width:100%; } table#change-history tbody th { width:16em; } /* TABLE SORTING */ - thead th a:link, thead th a:visited { color:#666; display:block; } table thead th.sorted { background-position:bottom left !important; } table thead th.sorted a { padding-right:13px; } @@ -149,7 +108,6 @@ table thead th.ascending a { background:url(../img/admin/arrow-down.gif) right . table thead th.descending a { background:url(../img/admin/arrow-up.gif) right .4em no-repeat; } /* MODULES */ - .module { border:1px solid #ccc; margin-bottom:5px; background:white; } .module p, .module ul, .module h3, .module h4, .module dl, .module pre { padding-left:10px; padding-right:10px; } .module blockquote { margin-left:12px; } @@ -173,7 +131,6 @@ textarea { vertical-align:top !important; } input[type=checkbox], input[type=radio] { border:none; } /* FORM BUTTONS */ - input[type=submit], input[type=button], .submit-row input { background:white url(../img/admin/nav-bg.gif) bottom repeat-x; padding:3px; } input[type=submit]:active, input[type=button]:active { background-image:url(../img/admin/nav-bg-reverse.gif); background-position:top; } input[type=submit].default, .submit-row input.default { border:2px solid #5b80b2; background:#7CA0C7 url(../img/admin/default-bg.gif) bottom repeat-x; font-weight:bold; color:white; } @@ -183,7 +140,6 @@ input[type=submit].default:active { background-image:url(../img/admin/default-bg .submit-row .float-left { padding-top:.1em; } /* FORM ROWS */ - .form-row { clear:both; padding:8px 12px; font-size:11px; } html>body .form-row { border-bottom:1px solid #eee; } .form-row:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } @@ -191,21 +147,18 @@ html>body .form-row { border-bottom:1px solid #eee; } form .form-row p { padding-left:0; font-size:11px; } /* FORM LABELS */ - form h4 { margin:0 !important; padding:0 !important; border:none !important; } label { font-weight:normal !important; color:#666; font-size:12px; } label.inline { margin-left:20px; } .required label, label.required { font-weight:bold !important; color:#333 !important; } /* RADIO BUTTONS */ - form ul.radiolist li { list-style-type:none; } form ul.radiolist label { float:none; display:inline; } form ul.inline { margin-left:0; padding:0; } form ul.inline li { float:left; padding-right:7px; } /* ALIGNED FIELDSETS */ - .aligned label { display:block; padding:0 1em 3px 0; float:left; text-align:left; width:8em; } .aligned label.inline { display:inline; float:none; } .colMS .aligned .vLargeTextField, .colMS .aligned .vXMLLargeTextField { width:350px; } @@ -217,14 +170,12 @@ form .aligned p.help { padding-left:38px; } .checkbox-row p.help { margin-left:0; padding-left:0 !important; } /* WIDE FIELDSETS */ - .wide label { width:15em !important; } form .wide p { margin-left:15em; } form .wide p.help { padding-left:38px; } .colM fieldset.wide .vLargeTextField, .colM fieldset.wide .vXMLLargeTextField { width:450px; } /* COLLAPSED FIELDSETS */ - fieldset.collapsed * { display:none; } fieldset.collapsed h2, fieldset.collapsed { display:block !important; } fieldset.collapsed .collapse-toggle { display: inline !important; } @@ -233,7 +184,6 @@ fieldset.collapse h2 a.collapse-toggle:hover { text-decoration:underline; } .hidden { display:none; } /* MESSAGES & ERRORS */ - ul.messagelist { padding:0 0 5px 0; margin:0; } ul.messagelist li { font-size:12px; display:block; padding:4px 5px 4px 25px; margin:0 0 3px 0; border-bottom:1px solid #ddd; color:#666; background:#ffc url(../img/admin/icon_success.gif) 5px .3em no-repeat; } .errornote { font-size:12px !important; display:block; padding:4px 5px 4px 25px; margin:0 0 3px 0; border:1px solid red; color:red;background:#ffc url(../img/admin/icon_error.gif) 5px .3em no-repeat; } @@ -245,7 +195,6 @@ td ul.errorlist li { margin:0 !important; } .error input, .error select { border:1px solid red; } /* ACTION ICONS */ - .addlink { padding-left:12px; background:url(../img/admin/icon_addlink.gif) 0 .2em no-repeat; } .changelink { padding-left:12px; background:url(../img/admin/icon_changelink.gif) 0 .2em no-repeat; } .deletelink { padding-left:12px; background:url(../img/admin/icon_deletelink.gif) 0 50% no-repeat; } @@ -253,7 +202,6 @@ a.deletelink:link, a.deletelink:visited { color:#CC3434; } a.deletelink:hover { color:#993333; } /* OBJECT TOOLS */ - .object-tools { font-size:10px; font-weight:bold; font-family:Arial,Helvetica,sans-serif; padding-left:0; margin-bottom:5px; float:right; position:relative; margin-top:-2.4em; margin-bottom:-2em; } .form-row .object-tools { margin-top:0; margin-bottom:0; } .object-tools li { display:block; float:left; background:url(../img/admin/tool-left.gif) 0 0 no-repeat; padding:0 0 0 8px; margin-left:2px; height:16px; } @@ -266,17 +214,14 @@ a.deletelink:hover { color:#993333; } .object-tools a.addlink:hover { background:#5b80b2 url(../img/admin/tooltag-add_over.gif) top right no-repeat; } /* INLINE CONTROLS */ - #inline-controls { font-weight:bold; font-size:12px; } #inline-specific-controls { margin-left:6px; padding:0 8px; border-left:6px solid #ccc; } /* BREADCRUMBS */ - p.breadcrumbs { font-size:11px; color:#ccc;text-align:left; } /* old breadcrumbs style */ div.breadcrumbs { background:white url(../img/admin/nav-bg-reverse.gif) 0 -10px repeat-x; padding:2px 8px 3px 8px; font-size:11px; color:#999; border-top:1px solid white; border-bottom:1px solid #ccc; text-align:left; } /* SELECTOR (FILTER INTERFACE) */ - .selector { width:580px; float:left; } .selector select { width:270px; height:170px; } .selector-available, .selector-chosen { float:left; width:270px; text-align:center; margin-bottom:5px; } @@ -297,7 +242,6 @@ a.selector-chooseall { width:7em; background:url(../img/admin/selector-addall.gi a.selector-clearall { background:url(../img/admin/selector-removeall.gif) left center no-repeat; } /* Stacked selectors for long items */ - .stacked { float:left; width:500px; } .stacked select { width:480px; height:100px; } .stacked .selector-available, .stacked .selector-chosen { width:480px; } @@ -310,20 +254,17 @@ a.selector-clearall { background:url(../img/admin/selector-removeall.gif) left c .stacked .selector-remove { background-image:url(../img/admin/selector_stacked-remove.gif); } /* DATE AND TIME */ - p.datetime { line-height:20px; margin:0; padding:0; color:#666; font-size:11px; font-weight:bold; } .datetime span { font-size:11px; font-weight:normal; white-space:nowrap; } .vDateField { margin-left:4px; } table p.datetime { font-size:10px; margin-left:0; padding-left:0; } /* FILE UPLOADS */ - p.file-upload { line-height:20px; margin:0; padding:0; color:#666; font-size:11px; font-weight:bold; } .file-upload a { font-weight:normal; } .file-upload .deletelink { margin-left:5px; } /* CALENDARS & CLOCKS */ - .calendarbox, .clockbox { margin:5px auto; width: 10em; text-align: center; background:white; position:relative; } .clockbox { width:6em; } .calendar { margin:0; padding: 0; } @@ -350,14 +291,12 @@ ul.timelist, .timelist li { list-style-type:none; margin:0; padding:0; } .timelist a { padding:2px; } /* ORDERING WIDGET */ - ul#orderthese { padding:0; margin:0; list-style-type:none; } ul#orderthese li { list-style-type:none; display:block; padding:0; margin:6px 0; width:214px; background:#f6f6f6; white-space:nowrap; overflow:hidden; } ul#orderthese li span { display:block; border:1px solid #e7e7e7; background:transparent url(../img/admin/nav-bg-grabber.gif) top left repeat-y; font-size:10px !important; padding:4px 6px 4px 12px; } ul#orderthese span:hover { background-color:#efefef; } /* PAGINATOR */ - .paginator { font-size:11px; padding-top:10px; padding-bottom:10px; line-height:22px; margin:0; border-top:1px solid #ddd; } .paginator a:link, .paginator a:visited { padding:2px 6px; border:solid 1px #ccc; background:white; text-decoration:none; } .paginator a.showall { padding:0 !important; border:none !important; } @@ -367,7 +306,6 @@ ul#orderthese span:hover { background-color:#efefef; } .paginator a:hover { color:white; background:#5b80b2; border-color:#036; } /* TEXT STYLES & MODIFIERS */ - .small { font-size:11px; } .tiny { font-size:10px; } p.tiny { margin-top:-2px; } @@ -386,7 +324,6 @@ p img, h1 img, h2 img, h3 img, h4 img, td img { vertical-align:middle; } .nowrap { white-space:nowrap; } /* CUSTOM FORM FIELDS */ - .vSelectMultipleField { vertical-align:top !important; } .vCheckboxField { border:none; } .vDateField, .vTimeField { margin-right:2px; } From 91c67bcd45facfc55abc8e7afcfc4af2732bac7f Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 18 Oct 2005 04:21:07 +0000 Subject: [PATCH 03/13] Added django.contrib.admin, with a staff_member_required decorator and code from AdminUserRequired middleware. Refs #627 git-svn-id: http://code.djangoproject.com/svn/django/trunk@921 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/__init__.py | 0 django/contrib/admin/views/__init__.py | 0 django/contrib/admin/views/decorators.py | 100 +++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 django/contrib/admin/__init__.py create mode 100644 django/contrib/admin/views/__init__.py create mode 100644 django/contrib/admin/views/decorators.py diff --git a/django/contrib/admin/__init__.py b/django/contrib/admin/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/django/contrib/admin/views/__init__.py b/django/contrib/admin/views/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py new file mode 100644 index 0000000000..44e1234ce4 --- /dev/null +++ b/django/contrib/admin/views/decorators.py @@ -0,0 +1,100 @@ +from django.core.extensions import DjangoContext, render_to_response +from django.conf.settings import SECRET_KEY +from django.models.auth import users +from django.utils import httpwrappers +import base64, md5 +import cPickle as pickle + +ERROR_MESSAGE = "Please enter a correct username and password. Note that both fields are case-sensitive." +LOGIN_FORM_KEY = 'this_is_the_login_form' + +def _display_login_form(request, error_message=''): + request.session.set_test_cookie() + if request.POST and request.POST.has_key('post_data'): + # User has failed login BUT has previously saved post data. + post_data = request.POST['post_data'] + elif request.POST: + # User's session must have expired; save their post data. + post_data = _encode_post_data(request.POST) + else: + post_data = _encode_post_data({}) + return render_to_response('admin/login', { + 'title': 'Log in', + 'app_path': request.path, + 'post_data': post_data, + 'error_message': error_message + }, context_instance=DjangoContext(request)) + +def _encode_post_data(post_data): + pickled = pickle.dumps(post_data) + pickled_md5 = md5.new(pickled + SECRET_KEY).hexdigest() + return base64.encodestring(pickled + pickled_md5) + +def _decode_post_data(encoded_data): + encoded_data = base64.decodestring(encoded_data) + pickled, tamper_check = encoded_data[:-32], encoded_data[-32:] + if md5.new(pickled + SECRET_KEY).hexdigest() != tamper_check: + from django.core.exceptions import SuspiciousOperation + raise SuspiciousOperation, "User may have tampered with session cookie." + return pickle.loads(pickled) + +def staff_member_required(view_func): + """ + Decorator for views that checks that the user is logged in and is a staff + member, displaying the login page if necessary. + """ + def _checklogin(request, *args, **kwargs): + if not request.user.is_anonymous() and request.user.is_staff: + # The user is valid. Continue to the admin page. + return view_func(request, *args, **kwargs) + + assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.middleware.sessions.SessionMiddleware'." + + # If this isn't already the login page, display it. + if not request.POST.has_key(LOGIN_FORM_KEY): + if request.POST: + message = "Please log in again, because your session has expired. "\ + "Don't worry: Your submission has been saved." + else: + message = "" + return _display_login_form(request, message) + + # Check that the user accepts cookies. + if not request.session.test_cookie_worked(): + message = "Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again." + return _display_login_form(request, message) + + # Check the password. + username = request.POST.get('username', '') + try: + user = users.get_object(username__exact=username, is_staff__exact=True) + except users.UserDoesNotExist: + message = ERROR_MESSAGE + if '@' in username: + # Mistakenly entered e-mail address instead of username? Look it up. + try: + user = users.get_object(email__exact=username) + except users.UserDoesNotExist: + message = "Usernames cannot contain the '@' character." + else: + message = "Your e-mail address is not your username. Try '%s' instead." % user.username + return _display_login_form(request, message) + + # The user data is correct; log in the user in and continue. + else: + if user.check_password(request.POST.get('password', '')): + request.session[users.SESSION_KEY] = user.id + if request.POST.has_key('post_data'): + post_data = _decode_post_data(request.POST['post_data']) + if post_data and not post_data.has_key(LOGIN_FORM_KEY): + # overwrite request.POST with the saved post_data, and continue + request.POST = post_data + request.user = user + return view_func(request, *args, **kwargs) + else: + request.session.delete_test_cookie() + return httpwrappers.HttpResponseRedirect(request.path) + else: + return _display_login_form(request, ERROR_MESSAGE) + + return _checklogin From 1dc6d4b26506fe3d8c5e72aa958b8e82ea9975be Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 18 Oct 2005 04:36:28 +0000 Subject: [PATCH 04/13] Changed django.views.admin.doc to use template.loader instead of template_loader git-svn-id: http://code.djangoproject.com/svn/django/trunk@922 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/views/admin/doc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django/views/admin/doc.py b/django/views/admin/doc.py index 64785385c4..e7e791b2e4 100644 --- a/django/views/admin/doc.py +++ b/django/views/admin/doc.py @@ -4,8 +4,8 @@ from django.conf import settings from django.models.core import sites from django.core.extensions import DjangoContext, render_to_response from django.core.exceptions import Http404, ViewDoesNotExist -from django.core import template, template_loader, urlresolvers -from django.core.template import defaulttags, defaultfilters +from django.core import template, urlresolvers +from django.core.template import defaulttags, defaultfilters, loader try: from django.parts.admin import doc except ImportError: @@ -223,7 +223,7 @@ def load_all_installed_template_libraries(): # Clear out and reload default tags template.registered_tags.clear() reload(defaulttags) - reload(template_loader) # template_loader defines the block/extends tags + reload(loader) # loader defines the block/extends tags # Load any template tag libraries from installed apps for e in templatetags.__path__: From aed1930133ad4e7970c8a7909283a59fb2e3fef2 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 18 Oct 2005 04:40:47 +0000 Subject: [PATCH 05/13] Moved django.views.admin.template and django.views.admin.doc to django.contrib.admin.views. Refs #627 git-svn-id: http://code.djangoproject.com/svn/django/trunk@923 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/conf/urls/admin.py | 22 +++++++++---------- .../admin => contrib/admin/views}/doc.py | 0 .../admin => contrib/admin/views}/template.py | 0 3 files changed, 11 insertions(+), 11 deletions(-) rename django/{views/admin => contrib/admin/views}/doc.py (100%) rename django/{views/admin => contrib/admin/views}/template.py (100%) diff --git a/django/conf/urls/admin.py b/django/conf/urls/admin.py index 841d50523e..b31f4de2c9 100644 --- a/django/conf/urls/admin.py +++ b/django/conf/urls/admin.py @@ -6,20 +6,20 @@ urlpatterns = ( ('^logout/$', 'django.views.auth.login.logout'), ('^password_change/$', 'django.views.registration.passwords.password_change'), ('^password_change/done/$', 'django.views.registration.passwords.password_change_done'), - ('^template_validator/$', 'django.views.admin.template.template_validator'), + ('^template_validator/$', 'django.contrib.admin.views.template.template_validator'), # Documentation - ('^doc/$', 'django.views.admin.doc.doc_index'), - ('^doc/bookmarklets/$', 'django.views.admin.doc.bookmarklets'), - ('^doc/tags/$', 'django.views.admin.doc.template_tag_index'), - ('^doc/filters/$', 'django.views.admin.doc.template_filter_index'), - ('^doc/views/$', 'django.views.admin.doc.view_index'), - ('^doc/views/jump/$', 'django.views.admin.doc.jump_to_view'), - ('^doc/views/(?P[^/]+)/$', 'django.views.admin.doc.view_detail'), - ('^doc/models/$', 'django.views.admin.doc.model_index'), - ('^doc/models/(?P[^/]+)/$', 'django.views.admin.doc.model_detail'), + ('^doc/$', 'django.contrib.admin.views.doc.doc_index'), + ('^doc/bookmarklets/$', 'django.contrib.admin.views.doc.bookmarklets'), + ('^doc/tags/$', 'django.contrib.admin.views.doc.template_tag_index'), + ('^doc/filters/$', 'django.contrib.admin.views.doc.template_filter_index'), + ('^doc/views/$', 'django.contrib.admin.views.doc.view_index'), + ('^doc/views/jump/$', 'django.contrib.admin.views.doc.jump_to_view'), + ('^doc/views/(?P[^/]+)/$', 'django.contrib.admin.views.doc.view_detail'), + ('^doc/models/$', 'django.contrib.admin.views.doc.model_index'), + ('^doc/models/(?P[^/]+)/$', 'django.contrib.admin.views.doc.model_detail'), # ('^doc/templates/$', 'django.views.admin.doc.template_index'), - ('^doc/templates/(?P