1
0
mirror of https://github.com/django/django.git synced 2025-06-05 11:39:13 +00:00

magic-removal: Merged to [2450]

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2451 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-03-01 03:21:51 +00:00
parent 53ac6f9782
commit e8cfcf28e6
7 changed files with 125 additions and 72 deletions

View File

@ -3,11 +3,11 @@
function showRelatedObjectLookupPopup(triggeringLink) { function showRelatedObjectLookupPopup(triggeringLink) {
var name = triggeringLink.id.replace(/^lookup_/, ''); var name = triggeringLink.id.replace(/^lookup_/, '');
var href var href;
if (triggeringLink.href.search(/\?/) >= 0) { if (triggeringLink.href.search(/\?/) >= 0) {
href = triggeringLink.href + '&pop=1'; href = triggeringLink.href + '&pop=1';
} else { } else {
href = triggeringLink.href + '?pop=1' href = triggeringLink.href + '?pop=1';
} }
var win = window.open(href, name, 'height=500,width=740,resizable=yes,scrollbars=yes'); var win = window.open(href, name, 'height=500,width=740,resizable=yes,scrollbars=yes');
win.focus(); win.focus();
@ -33,12 +33,12 @@ function showAddAnotherPopup(triggeringLink) {
} }
function dismissAddAnotherPopup(win, newId, newRepr) { function dismissAddAnotherPopup(win, newId, newRepr) {
var name = win.name.replace(/___/g, '.') var name = win.name.replace(/___/g, '.');
var elem = document.getElementById(name); var elem = document.getElementById(name);
if (elem) { if (elem) {
if (elem.nodeName == 'SELECT') { if (elem.nodeName == 'SELECT') {
var o = new Option(newRepr, newId); var o = new Option(newRepr, newId);
elem.options[elem.options.length] = o elem.options[elem.options.length] = o;
elem.selectedIndex = elem.length - 1; elem.selectedIndex = elem.length - 1;
} else if (elem.nodeName == 'INPUT') { } else if (elem.nodeName == 'INPUT') {
elem.value = newId; elem.value = newId;

View File

@ -102,15 +102,17 @@ function Calendar(div_id, callback) {
this.today = new Date(); this.today = new Date();
this.currentMonth = this.today.getMonth() + 1; this.currentMonth = this.today.getMonth() + 1;
this.currentYear = this.today.getFullYear(); this.currentYear = this.today.getFullYear();
this.drawCurrent = function() { }
Calendar.prototype = {
drawCurrent: function() {
CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback); CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback);
} },
this.drawDate = function(month, year) { drawDate: function(month, year) {
this.currentMonth = month; this.currentMonth = month;
this.currentYear = year; this.currentYear = year;
this.drawCurrent(); this.drawCurrent();
} },
this.drawPreviousMonth = function() { drawPreviousMonth: function() {
if (this.currentMonth == 1) { if (this.currentMonth == 1) {
this.currentMonth = 12; this.currentMonth = 12;
this.currentYear--; this.currentYear--;
@ -119,8 +121,8 @@ function Calendar(div_id, callback) {
this.currentMonth--; this.currentMonth--;
} }
this.drawCurrent(); this.drawCurrent();
} },
this.drawNextMonth = function() { drawNextMonth: function() {
if (this.currentMonth == 12) { if (this.currentMonth == 12) {
this.currentMonth = 1; this.currentMonth = 1;
this.currentYear++; this.currentYear++;
@ -129,12 +131,12 @@ function Calendar(div_id, callback) {
this.currentMonth++; this.currentMonth++;
} }
this.drawCurrent(); this.drawCurrent();
} },
this.drawPreviousYear = function() { drawPreviousYear: function() {
this.currentYear--; this.currentYear--;
this.drawCurrent(); this.drawCurrent();
} },
this.drawNextYear = function() { drawNextYear: function() {
this.currentYear++; this.currentYear++;
this.drawCurrent(); this.drawCurrent();
} }

View File

@ -70,7 +70,7 @@ function findPosX(obj) {
var curleft = 0; var curleft = 0;
if (obj.offsetParent) { if (obj.offsetParent) {
while (obj.offsetParent) { while (obj.offsetParent) {
curleft += obj.offsetLeft curleft += obj.offsetLeft;
obj = obj.offsetParent; obj = obj.offsetParent;
} }
} else if (obj.x) { } else if (obj.x) {
@ -83,7 +83,7 @@ function findPosY(obj) {
var curtop = 0; var curtop = 0;
if (obj.offsetParent) { if (obj.offsetParent) {
while (obj.offsetParent) { while (obj.offsetParent) {
curtop += obj.offsetTop curtop += obj.offsetTop;
obj = obj.offsetParent; obj = obj.offsetParent;
} }
} else if (obj.y) { } else if (obj.y) {
@ -130,7 +130,7 @@ Date.prototype.getHourMinute = function() {
// String object extensions // String object extensions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
String.prototype.pad_left = function(pad_length, pad_string) { String.prototype.pad_left = function(pad_length, pad_string) {
new_string = this; var new_string = this;
for (var i = 0; new_string.length < pad_length; i++) { for (var i = 0; new_string.length < pad_length; i++) {
new_string = pad_string + new_string; new_string = pad_string + new_string;
} }

View File

@ -4,24 +4,30 @@
*/ */
/* Finds the index of the first occurence of item in the array, or -1 if not found */ /* Finds the index of the first occurence of item in the array, or -1 if not found */
Array.prototype.indexOf = function(item) { if (typeof Array.prototype.indexOf == 'undefined') {
for (var i = 0; i < this.length; i++) { Array.prototype.indexOf = function(item) {
if (this[i] == item) { var len = this.length;
return i; for (var i = 0; i < len; i++) {
if (this[i] == item) {
return i;
}
} }
} return -1;
return -1; };
}; }
/* Returns an array of items judged 'true' by the passed in test function */ /* Returns an array of items judged 'true' by the passed in test function */
Array.prototype.filter = function(test) { if (typeof Array.prototype.filter == 'undefined') {
var matches = []; Array.prototype.filter = function(test) {
for (var i = 0; i < this.length; i++) { var matches = [];
if (test(this[i])) { var len = this.length;
matches[matches.length] = this[i]; for (var i = 0; i < len; i++) {
if (test(this[i])) {
matches[matches.length] = this[i];
}
} }
} return matches;
return matches; };
}; }
var monthNames = gettext("January February March April May June July August September October November December").split(" "); var monthNames = gettext("January February March April May June July August September October November December").split(" ");
var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" "); var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" ");

View File

@ -111,6 +111,9 @@ def get_date_trunc_sql(lookup_type, field_name):
# http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html # http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
# MySQL doesn't support DATE_TRUNC, so we fake it by subtracting intervals. # MySQL doesn't support DATE_TRUNC, so we fake it by subtracting intervals.
# If you know of a better way to do this, please file a Django ticket. # If you know of a better way to do this, please file a Django ticket.
# Note that we can't use DATE_FORMAT directly because that causes the output
# to be a string rather than a datetime object, and we need MySQL to return
# a date so that it's typecasted properly into a Python datetime object.
subtractions = ["interval (DATE_FORMAT(%s, '%%%%s')) second - interval (DATE_FORMAT(%s, '%%%%i')) minute - interval (DATE_FORMAT(%s, '%%%%H')) hour" % (field_name, field_name, field_name)] subtractions = ["interval (DATE_FORMAT(%s, '%%%%s')) second - interval (DATE_FORMAT(%s, '%%%%i')) minute - interval (DATE_FORMAT(%s, '%%%%H')) hour" % (field_name, field_name, field_name)]
if lookup_type in ('year', 'month'): if lookup_type in ('year', 'month'):
subtractions.append(" - interval (DATE_FORMAT(%s, '%%%%e')-1) day" % field_name) subtractions.append(" - interval (DATE_FORMAT(%s, '%%%%e')-1) day" % field_name)

View File

@ -255,6 +255,7 @@ TECHNICAL_500_TEMPLATE = """
hideAll(getElementsByClassName(document, 'table', 'vars')); hideAll(getElementsByClassName(document, 'table', 'vars'));
hideAll(getElementsByClassName(document, 'ol', 'pre-context')); hideAll(getElementsByClassName(document, 'ol', 'pre-context'));
hideAll(getElementsByClassName(document, 'ol', 'post-context')); hideAll(getElementsByClassName(document, 'ol', 'post-context'));
hideAll(getElementsByClassName(document, 'div', 'pastebin'));
} }
function toggle() { function toggle() {
for (var i = 0; i < arguments.length; i++) { for (var i = 0; i < arguments.length; i++) {
@ -273,6 +274,13 @@ TECHNICAL_500_TEMPLATE = """
s.innerHTML = s.innerHTML == uarr ? darr : uarr; s.innerHTML = s.innerHTML == uarr ? darr : uarr;
return false; return false;
} }
function switchPastebinFriendly(link) {
s1 = "Switch to copy-and-paste view";
s2 = "Switch back to interactive view";
link.innerHTML = link.innerHTML == s1 ? s2 : s1;
toggle('browserTraceback', 'pastebinTraceback');
return false;
}
//--> //-->
</script> </script>
</head> </head>
@ -341,47 +349,71 @@ TECHNICAL_500_TEMPLATE = """
{% endif %} {% endif %}
<div id="traceback"> <div id="traceback">
<h2>Traceback <span>(innermost last)</span></h2> <h2>Traceback <span>(innermost last)</span></h2>
<ul class="traceback"> <div class="commands"><a href="#" onclick="return switchPastebinFriendly(this);">Switch to copy-and-paste view</a></div>
{% for frame in frames %} <br/>
<li class="frame"> <div id="browserTraceback">
<code>{{ frame.filename }}</code> in <code>{{ frame.function }}</code> <ul class="traceback">
{% for frame in frames %}
<li class="frame">
<code>{{ frame.filename }}</code> in <code>{{ frame.function }}</code>
{% if frame.context_line %} {% if frame.context_line %}
<div class="context" id="c{{ frame.id }}"> <div class="context" id="c{{ frame.id }}">
{% if frame.pre_context %} {% if frame.pre_context %}
<ol start="{{ frame.pre_context_lineno|add:"1" }}" class="pre-context" id="pre{{ frame.id }}">{% for line in frame.pre_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol> <ol start="{{ frame.pre_context_lineno|add:"1" }}" class="pre-context" id="pre{{ frame.id }}">{% for line in frame.pre_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
{% endif %} {% endif %}
<ol start="{{ frame.lineno|add:"1" }}" class="context-line"><li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ frame.context_line|escape }} <span>...</span></li></ol> <ol start="{{ frame.lineno|add:"1" }}" class="context-line"><li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ frame.context_line|escape }} <span>...</span></li></ol>
{% if frame.post_context %} {% if frame.post_context %}
<ol start='{{ frame.lineno|add:"2" }}' class="post-context" id="post{{ frame.id }}">{% for line in frame.post_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol> <ol start='{{ frame.lineno|add:"2" }}' class="post-context" id="post{{ frame.id }}">{% for line in frame.post_context %}<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')">{{ line|escape }}</li>{% endfor %}</ol>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
{% if frame.vars %} {% if frame.vars %}
<div class="commands"> <div class="commands">
<a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>&#x25b6;</span> Local vars</a> <a href="#" onclick="return varToggle(this, '{{ frame.id }}')"><span>&#x25b6;</span> Local vars</a>
</div> </div>
<table class="vars" id="v{{ frame.id }}"> <table class="vars" id="v{{ frame.id }}">
<thead> <thead>
<tr>
<th>Variable</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{% for var in frame.vars|dictsort:"0" %}
<tr> <tr>
<td>{{ var.0 }}</td> <th>Variable</th>
<td class="code"><div>{{ var.1|pprint|escape }}</div></td> <th>Value</th>
</tr> </tr>
{% endfor %} </thead>
</tbody> <tbody>
</table> {% for var in frame.vars|dictsort:"0" %}
{% endif %} <tr>
</li> <td>{{ var.0 }}</td>
{% endfor %} <td class="code"><div>{{ var.1|pprint|escape }}</div></td>
</ul> </tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
<div id="pastebinTraceback" class="pastebin">
<table>
<tbody>
<tr>
<td>
<code>
Traceback (most recent call last):<br/>
{% for frame in frames %}
File "{{ frame.filename }}" in {{ frame.function }}<br/>
{% if frame.context_line %}
&nbsp;&nbsp;{{ frame.lineno|add:"1" }}. {{ frame.context_line|escape }}<br/>
{% endif %}
{% endfor %}<br/>
&nbsp;&nbsp;{{ exception_type }} at {{ request.path }}<br/>
&nbsp;&nbsp;{{ exception_value|escape }}</code>
</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
<div id="requestinfo"> <div id="requestinfo">

View File

@ -14,7 +14,7 @@ the appropriate options to ``use_setuptools()``.
This file can also be run as a script to install or upgrade setuptools. This file can also be run as a script to install or upgrade setuptools.
""" """
import sys import sys
DEFAULT_VERSION = "0.6a9" DEFAULT_VERSION = "0.6a10"
DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3]
md5_data = { md5_data = {
@ -22,6 +22,10 @@ md5_data = {
'setuptools-0.5a13-py2.4.egg': 'ede4be600e3890e06d4ee5e0148e092a', 'setuptools-0.5a13-py2.4.egg': 'ede4be600e3890e06d4ee5e0148e092a',
'setuptools-0.6a1-py2.3.egg': 'ee819a13b924d9696b0d6ca6d1c5833d', 'setuptools-0.6a1-py2.3.egg': 'ee819a13b924d9696b0d6ca6d1c5833d',
'setuptools-0.6a1-py2.4.egg': '8256b5f1cd9e348ea6877b5ddd56257d', 'setuptools-0.6a1-py2.4.egg': '8256b5f1cd9e348ea6877b5ddd56257d',
'setuptools-0.6a10-py2.3.egg': '162d8357f1aff2b0349c6c247ee62987',
'setuptools-0.6a10-py2.4.egg': '803a2d8db501c1ac3b5b6fb4e907f788',
'setuptools-0.6a10dev_r42346-py2.3.egg': 'a7899272cfceb6aa60094ae8928b8077',
'setuptools-0.6a10dev_r42346-py2.4.egg': '5d42a64adca9aedb409f83ecf22156a5',
'setuptools-0.6a2-py2.3.egg': 'b98da449da411267c37a738f0ab625ba', 'setuptools-0.6a2-py2.3.egg': 'b98da449da411267c37a738f0ab625ba',
'setuptools-0.6a2-py2.4.egg': 'be5b88bc30aed63fdefd2683be135c3b', 'setuptools-0.6a2-py2.4.egg': 'be5b88bc30aed63fdefd2683be135c3b',
'setuptools-0.6a3-py2.3.egg': 'ee0e325de78f23aab79d33106dc2a8c8', 'setuptools-0.6a3-py2.3.egg': 'ee0e325de78f23aab79d33106dc2a8c8',
@ -123,8 +127,14 @@ help). I will attempt to download it for you (from
%s), but %s), but
you may need to enable firewall access for this script first. you may need to enable firewall access for this script first.
I will start the download in %d seconds. I will start the download in %d seconds.
(Note: if this machine does not have network access, please obtain the file
%s
and place it in this directory before rerunning this script.)
---------------------------------------------------------------------------""", ---------------------------------------------------------------------------""",
version, download_base, delay version, download_base, delay, url
); from time import sleep; sleep(delay) ); from time import sleep; sleep(delay)
log.warn("Downloading %s", url) log.warn("Downloading %s", url)
src = urllib2.urlopen(url) src = urllib2.urlopen(url)