Skip to content

Commit a6cba5c

Browse files
committed
document theme update
1 parent f7c4cc8 commit a6cba5c

25 files changed

+524
-6
lines changed

README.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,38 @@ You will need to update your *settings.py*::
8383
"django_excel.TemporaryExcelFileUploadHandler")
8484

8585

86+
Usage
87+
======
88+
89+
Here is the example viewing function codes::
90+
91+
from django.shortcuts import render_to_response
92+
from django.http import HttpResponseBadRequest
93+
from django import forms
94+
from django.template import RequestContext
95+
import django_excel as excel
96+
97+
class UploadFileForm(forms.Form):
98+
file = forms.FileField()
99+
100+
def upload(request):
101+
if request.method == "POST":
102+
form = UploadFileForm(request.POST, request.FILES)
103+
if form.is_valid():
104+
filehandle = request.FILES['file']
105+
return excel.make_response(filehandle.get_sheet(), "csv")
106+
else:
107+
return HttpResponseBadRequest()
108+
else:
109+
form = UploadFileForm()
110+
return render_to_response('upload_form.html',
111+
{'form': form},
112+
context_instance=RequestContext(request))
113+
114+
def download(request):
115+
sheet = excel.pe.Sheet([[1, 2],[3, 4]])
116+
return excel.make_response(sheet, "csv")
117+
86118
Dependencies
87119
=============
88120

django_excel/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def load_book(self):
1717
return pe.load_book_from_memory(self._get_file_extension(), self.file.read())
1818

1919

20-
class ExcelMemoryFile(ExcelMixin, InMemoryUploadedFile):
20+
class ExcelInMemoryUploadedFile(ExcelMixin, InMemoryUploadedFile):
2121
pass
2222

2323

24-
class ExcelFile(ExcelMixin, TemporaryUploadedFile):
24+
class TemporaryUploadedExcelFile(ExcelMixin, TemporaryUploadedFile):
2525
pass
2626

2727

@@ -30,7 +30,7 @@ def file_complete(self, file_size):
3030
if not self.activated:
3131
return
3232
self.file.seek(0)
33-
return ExcelMemoryFile(
33+
return ExcelInMemoryUploadedFile(
3434
file=self.file,
3535
field_name=self.field_name,
3636
name=self.file_name,
@@ -46,7 +46,7 @@ def new_file(self, file_name, *args, **kwargs):
4646
Create the file object to append to as data is coming in.
4747
"""
4848
super(TemporaryFileUploadHandler, self).new_file(file_name, *args, **kwargs)
49-
self.file = ExcelFile(self.file_name, self.content_type, 0, self.charset, self.content_type_extra)
49+
self.file = TemporaryUploadedExcelFile(self.file_name, self.content_type, 0, self.charset, self.content_type_extra)
5050

5151

5252
webio.ExcelResponse = HttpResponse
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{%- extends "epub/epub-cover.html" %}
2+
3+
{% block content %}
4+
<div class="epub-cover">
5+
<h1>Django Documentation</h1>
6+
<h2><em>Release {{ release }}</em></h2>
7+
<h3>{{ copyright }}</h3>
8+
<p>{{ last_updated }}</p>
9+
</div>
10+
{% endblock %}
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
h1 { margin-top: 0; }
2+
3+
/* Keep lists a bit narrow to maximize page estate regarding width. */
4+
ol, ul {
5+
margin: 0;
6+
padding: 0 0 0 1.3em;
7+
}
8+
9+
/* Images should never exceed the width of the page. */
10+
img { max-width: 100%; }
11+
12+
/* Don't display URL after links, this is not print. */
13+
.link-target { display: none; }
14+
15+
/* This is the front cover page of the book. */
16+
.epub-cover { text-align: center; }
17+
.epub-cover h1 { margin: 4em 0 0 0; }
18+
.epub-cover h2 { margin: 1em 0; }
19+
.epub-cover h3 { margin: 3em 0 2em 0; }
20+
21+
/* Code examples should never exceed the width of the page, so wrap instead. */
22+
pre, span.pre { white-space: pre-wrap; }
23+
24+
pre {
25+
background-color: #f6f6f6;
26+
border: 0;
27+
padding: 0.5em;
28+
font-size: 90%;
29+
}
30+
31+
/* Header for some code blocks. */
32+
.snippet-filename {
33+
background-color: #393939;
34+
color: white;
35+
margin: 0;
36+
padding: 0.5em;
37+
font: bold 90% monospace;
38+
}
39+
.snippet-filename + .highlight > pre,
40+
.snippet-filename + pre {
41+
margin-top: 0;
42+
}
43+
44+
a:link, a:visited { color: #396623; }
45+
a:hover { color: #1d3311; }
46+
47+
/* Use special styled note boxes from the default theme, but with the left side
48+
fitted after the icon, to allow text resizing with breaking. */
49+
.note, .admonition {
50+
background-position: 9px 0.8em;
51+
background-repeat: no-repeat;
52+
padding: 0.8em 1em 0.8em 65px;
53+
margin: 1em 0;
54+
border: 0.01em solid black;
55+
}
56+
57+
.note, .admonition { background-image: url(docicons-note.png); }
58+
div.admonition-philosophy { background-image: url(docicons-philosophy.png); }
59+
div.admonition-behind-the-scenes { background-image: url(docicons-behindscenes.png); }
60+
.admonition.warning { background-image: url(docicons-warning.png); }
61+
62+
.admonition-title {
63+
font-weight: bold;
64+
margin: 0;
65+
}
66+
67+
.admonition .last { margin-bottom: 0; }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[theme]
2+
inherit = epub
3+
stylesheet = epub.css
4+
pygments_style = trac
5+
6+
[options]
7+
relbar1 = false
8+
footer = false
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% extends "basic/genindex.html" %}
2+
3+
{% block bodyclass %}{% endblock %}
4+
{% block sidebarwrapper %}{% endblock %}

0 commit comments

Comments
 (0)