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

View File

@ -10,15 +10,19 @@ import datetime
class PersonForm(forms.ModelForm): class PersonForm(forms.ModelForm):
class Meta: class Meta:
model = Person 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 NameForm(forms.ModelForm):
class Meta: class Meta:
model = Name model = Name
# Exclude these, so they don't get checked: # Exclude these, so they don't get checked:
exclude = ["order", "calendar", "modifier", exclude = ["order", "calendar", "modifier",
"quality", "quality",
#"quality_estimated", "quality_calculated", #"quality_estimated", "quality_calculated",
#"quality_interpreted", #"quality_interpreted",
"year1", "day1", "month1", "year1", "day1", "month1",

View File

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

View File

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