Edit names sorta working again

svn: r18311
This commit is contained in:
Doug Blank 2011-10-13 02:33:20 +00:00
parent 38308df518
commit fd34323139
4 changed files with 31 additions and 13 deletions

View File

@ -26,10 +26,11 @@
{% endif %}
<tr>
<td class="ColumnAttribute">{{form.surname.label}}:</td>
<td class="ColumnValue" id="data">{% render form.surname user action %}</td>
<td class="ColumnValue" id="data"></td>
<td class="ColumnAttribute">{{form.prefix.label}}:</td>
<td class="ColumnValue" id="data">{% render form.prefix user action %}</td>
<td class="ColumnValue" id="data"></td>
</tr>
<tr>
<td class="ColumnAttribute">{{form.first_name.label}}:</td>
<td class="ColumnValue" id="data">{% render form.first_name user action %}</td>
<td class="ColumnAttribute">{{form.call.label}}:</td>
@ -41,8 +42,6 @@
<td class="ColumnAttribute">{{form.suffix.label}}:</td>
<td class="ColumnValue" id="data">{% render form.suffix user action %}</td>
<tr>
<td class="ColumnAttribute">{{form.patronymic.label}}:</td>
<td class="ColumnValue" id="data">{% render form.patronymic user action %}</td>
<td class="ColumnAttribute">{{form.name_type.label}}:</td>
<td class="ColumnValue" id="data">{% render form.name_type user action %}</td>
</tr>

View File

@ -10,15 +10,19 @@ import datetime
class PersonForm(forms.ModelForm):
class Meta:
model = Person
exclude = ["death", "birth", "handle", "birth_ref_index", "death_ref_index"]
exclude = ["death", "birth", "handle"]
surname = forms.CharField(required=False,
widget=TextInput(attrs={'size':'30'}))
prefix = forms.CharField(required=False,
widget=TextInput(attrs={'size':'30'}))
class NameForm(forms.ModelForm):
class Meta:
model = Name
# Exclude these, so they don't get checked:
exclude = ["order", "calendar", "modifier",
"quality",
"quality",
#"quality_estimated", "quality_calculated",
#"quality_interpreted",
"year1", "day1", "month1",

View File

@ -117,7 +117,7 @@ def fix_person(request, person):
names = person.name_set.all().order_by("order")
if names.count() == 0:
name = Name(person=person,
surname="? Fixed",
surname_set=[Surname(surname="? Fixed")],
first_name="? Missing name",
preferred=True)
name.save()
@ -233,7 +233,7 @@ def view_name_detail(request, handle, order, action="view"):
else:
return render_to_response(view_template, context)
def send_file(request, filename):
def send_file(request, filename, mimetype):
"""
Send a file through Django without loading the whole file into
memory at once. The FileWrapper will turn the file object into an
@ -241,16 +241,20 @@ def send_file(request, filename):
"""
from django.core.servers.basehttp import FileWrapper
wrapper = FileWrapper(file(filename))
response = HttpResponse(wrapper, mimetype='application/pdf')
response = HttpResponse(wrapper, mimetype=mimetype)
path, base = os.path.split(filename)
response['Content-Length'] = os.path.getsize(filename)
response['Content-Disposition'] = 'attachment; filename=%s' % base
return response
def process_action(request, view, handle, action):
from cli.plug import run_report
from dbdjango import export_file
db = DbDjango()
if view == "report":
if request.user.is_authenticated():
profile = request.user.get_profile()
report = Report.objects.get(handle=handle)
if action == "run":
args = {}
if request.GET.has_key("options"):
@ -260,9 +264,17 @@ def process_action(request, view, handle, action):
if "=" in pair:
key, value = pair.split("=", 1)
args[str(key)] = str(value)
filename = "/tmp/%s-%s.pdf" % (str(profile.user.username), str(handle))
run_report(db, handle, off="pdf", of=filename, **args)
return send_file(request, filename)
if report.report_type == "textreport":
filename = "/tmp/%s-%s.pdf" % (str(profile.user.username), str(handle))
run_report(db, handle, off="pdf", of=filename, **args)
mimetype = 'application/pdf'
elif report.report_type == "export":
filename = "/tmp/%s-%s.ged" % (str(profile.user.username), str(handle))
export_file(db, filename, lambda n: n) # callback
mimetype = 'text/plain'
else:
pass # FIXME: error
return send_file(request, filename, mimetype)
# If failure, just fail for now:
context = RequestContext(request)
context["tview"] = "Results"
@ -670,7 +682,7 @@ def view(request, view):
.filter(Q(name__icontains=search)) \
.order_by("name")
else:
object_list = Report.objects.all()
object_list = Report.objects.all().order_by("name")
view_template = 'view_report.html'
total = Report.objects.all().count()
else:

View File

@ -109,6 +109,9 @@ for table, entries in [("grampsdb.config",
(("name", '"summary"'),
("handle", '"summary"'),
("report_type", '"textreport"')),
(("name", '"GEDCOM Export"'),
("handle", '"gedcom_export"'),
("report_type", '"export"')),
])]:
entry_count = 0
for entry in entries: