Changes to: 1) bring trunk up to where gramps35 webapp was, 2) to bring old code up to python3 and pygobject use, and 3) use Django 1.4; (not all of webapp is back to working state yet)

svn: r20735
This commit is contained in:
Doug Blank 2012-12-01 22:13:30 +00:00
parent 8759bc0c03
commit 03bafbd9e6
49 changed files with 76742 additions and 2563 deletions

View File

@ -9,7 +9,7 @@
<meta name="generator" content="Gramps 3.2.0-0.SVN12859M http://gramps-project.org/" />
<meta name="author" content="" />
{% endblock %}
<link href="/images/favicon2.ico" type="image/x-icon" rel="shortcut icon" />
<link href="/images/ped24.ico" type="image/x-icon" rel="shortcut icon" />
{% block css %}
<link media="screen" href="/styles/css/{{css_theme}}" type="text/css" rel="stylesheet" />
<link media="print" href="/styles/css/Web_Print-Default.css" type="text/css" rel="stylesheet" />
@ -267,6 +267,16 @@ function setReturnValues() {
}
}
}
function buttonOver(button) {
button.style.backgroundColor = "white";
button.style.border = "1px solid gray";
}
function buttonOut(button) {
button.style.backgroundColor = "lightgray";
button.style.border = "1px solid lightgray";
}
//-->
</SCRIPT>

View File

@ -166,9 +166,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Citation" "/citation/add" args %}
{% make_button "Edit Citation" "/citation/%s/edit" citation.handle args %}
{% make_button "Delete Citation" "/citation/%s/delete" citation.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Citation" "/citation/add" args %}
{% make_button "?Edit Citation" "/citation/%s/edit" citation.handle args %}
{% make_button "-Delete Citation" "/citation/%s/delete" citation.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -37,8 +37,12 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Citation" "/citation/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Citation" "/citation/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -121,9 +121,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Event" "/event/add" args %}
{% make_button "Edit Event" "/event/%s/edit" event.handle args %}
{% make_button "Delete Event" "/event/%s/delete" event.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Event" "/event/add" args %}
{% make_button "?Edit Event" "/event/%s/edit" event.handle args %}
{% make_button "-Delete Event" "/event/%s/delete" event.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -37,8 +37,12 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Event" "/event/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Event" "/event/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -60,8 +60,12 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Family" "/family/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Family" "/family/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -190,9 +190,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Family" "/family/add" args %}
{% make_button "Edit Family" "/family/%s/edit" family.handle args %}
{% make_button "Delete Family" "/family/%s/delete" family.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Family" "/family/add" args %}
{% make_button "?Edit Family" "/family/%s/edit" family.handle args %}
{% make_button "-Delete Family" "/family/%s/delete" family.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -2,7 +2,6 @@
{% load my_tags %}
{% block table_data %}
<table cellspacing="0" class="infolist surname" width="95%">
<thead>
<tr>
@ -43,8 +42,12 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Media" "/media/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Media" "/media/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -95,9 +95,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Media" "/media/add" args %}
{% make_button "Edit Media" "/media/%s/edit" media.handle args %}
{% make_button "Delete Media" "/media/%s/delete" media.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Media" "/media/add" args %}
{% make_button "?Edit Media" "/media/%s/edit" media.handle args %}
{% make_button "-Delete Media" "/media/%s/delete" media.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -134,9 +134,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Save"/>
{% else %}
{% make_button "Add Name" "/person/%s/name/add" person.handle args %}
{% make_button "Edit Name" "/person/%s/name/%s/edit" person.handle order args %}
{% make_button "Delete Name" "/person/%s/name/%s/delete" person.handle order args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Name" "/person/%s/name/add" person.handle args %}
{% make_button "?Edit Name" "/person/%s/name/%s/edit" person.handle order args %}
{% make_button "-Delete Name" "/person/%s/name/%s/delete" person.handle order args %}
</div>
{% endifequal %}
{% endifequal %}
{% else %}

View File

@ -102,9 +102,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Note" "/note/add" args %}
{% make_button "Edit Note" "/note/%s/edit" note.handle args %}
{% make_button "Delete Note" "/note/%s/delete" note.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Note" "/note/add" args %}
{% make_button "?Edit Note" "/note/%s/edit" note.handle args %}
{% make_button "-Delete Note" "/note/%s/delete" note.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -42,8 +42,12 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Note" "/note/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Note" "/note/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -19,15 +19,10 @@
<br/><i>Available search terms</i>: <b>{{search_terms}}</b>
</form>
</div>
{% paginator %}
<div style="overflow:auto; height:500px;width:800px;">
<div style="overflow:auto; height:300px;width:800px;">
{% block table_data %} <table></table> {% endblock %}
</div>
{% include "paginator.html" %}
{% block admin_functions %}{% endblock %}
{% endblock %}

View File

@ -56,9 +56,13 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Person" "/person/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Person" "/person/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -159,9 +159,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Person" "/person/add" args %}
{% make_button "Edit Person" "/person/%s/edit" person.handle args %}
{% make_button "Delete Person" "/person/%s/delete" person.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Person" "/person/add" args %}
{% make_button "?Edit Person" "/person/%s/edit" person.handle args %}
{% make_button "-Delete Person" "/person/%s/delete" person.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -134,9 +134,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Place" "/place/add" args %}
{% make_button "Edit Place" "/place/%s/edit" place.handle args %}
{% make_button "Delete Place" "/place/%s/delete" place.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Place" "/place/add" args %}
{% make_button "?Edit Place" "/place/%s/edit" place.handle args %}
{% make_button "-Delete Place" "/place/%s/delete" place.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -27,8 +27,12 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Places" "/place/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Places" "/place/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -31,8 +31,12 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Repository" "/repository/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Repository" "/repository/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -86,9 +86,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Repository" "/repository/add" args %}
{% make_button "Edit Repository" "/repository/%s/edit" repository.handle args %}
{% make_button "Delete Repository" "/repository/%s/delete" repository.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Repository" "/repository/add" args %}
{% make_button "?Edit Repository" "/repository/%s/edit" repository.handle args %}
{% make_button "-Delete Repository" "/repository/%s/delete" repository.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -95,9 +95,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Source" "/source/add" args %}
{% make_button "Edit Source" "/source/%s/edit" source.handle args %}
{% make_button "Delete Source" "/source/%s/delete" source.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Source" "/source/add" args %}
{% make_button "?Edit Source" "/source/%s/edit" source.handle args %}
{% make_button "-Delete Source" "/source/%s/delete" source.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -33,8 +33,12 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Source" "/source/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Source" "/source/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -71,9 +71,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Save">
{% else %}
{% make_button "Add Surname" "/person/%s/name/%s/surname/add" person.handle order args %}
{% make_button "Edit Surname" "/person/%s/name/%s/surname/%s/edit" person.handle order sorder args %}
{% make_button "Delete Surname" "/person/%s/name/%s/surname/%s/delete" person.handle order sorder args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Surname" "/person/%s/name/%s/surname/add" person.handle order args %}
{% make_button "?Edit Surname" "/person/%s/name/%s/surname/%s/edit" person.handle order sorder args %}
{% make_button "-Delete Surname" "/person/%s/name/%s/surname/%s/delete" person.handle order sorder args %}
</div>
{% endif %}
{% endif %}
{% endif %}

View File

@ -66,9 +66,11 @@
<input type="hidden" name="page" value="{{page}}"/>
<input type="submit" value="Create"/>
{% else %}
{% make_button "Add Tag" "/tag/add" args %}
{% make_button "Edit Tag" "/tag/%s/edit" tag.handle args %}
{% make_button "Delete Tag" "/tag/%s/delete" tag.handle args %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px; clear: both;">
{% make_button "+Add Tag" "/tag/add" args %}
{% make_button "?Edit Tag" "/tag/%s/edit" tag.handle args %}
{% make_button "-Delete Tag" "/tag/%s/delete" tag.handle args %}
</div>
{% endifequal %}
{% endif %}
{% else %}

View File

@ -31,8 +31,12 @@
</tbody>
</table>
{% if user.is_superuser %}
{% make_button "Add Tag" "/tag/add" args %}
{% endif %}
{% endblock %}
{% block admin_functions %}
{% if user.is_superuser %}
<div style="background-color: lightgray; padding: 2px 0px 0px 2px">
{% make_button "+Add Tag" "/tag/add" args %}
</div>
{% endif %}
{% endblock %}

View File

@ -70,13 +70,13 @@ class Cursor(object):
def __iter__(self):
return self.__next__()
def __next__(self):
for item in self.model.all():
yield (item.handle, self.func(item.handle))
for handle in self.model.keys():
yield (handle, self.func(handle))
def __exit__(self, *args, **kwargs):
pass
def iter(self):
for item in self.model.all():
yield (item.handle, self.func(item.handle))
for handle in self.model.keys():
yield (handle, self.func(handle))
yield None
class Bookmarks:
@ -673,9 +673,21 @@ class DictionaryDb(DbWriteBase, DbReadBase):
def get_family_cursor(self):
return Cursor(self.family_map, self.get_raw_family_data).iter()
def get_events_cursor(self):
def get_event_cursor(self):
return Cursor(self.event_map, self.get_raw_event_data).iter()
def get_note_cursor(self):
return Cursor(self.note_map, self.get_raw_note_data).iter()
def get_tag_cursor(self):
return Cursor(self.tag_map, self.get_raw_tag_data).iter()
def get_repository_cursor(self):
return Cursor(self.repository_map, self.get_raw_repository_data).iter()
def get_media_cursor(self):
return Cursor(self.media_map, self.get_raw_object_data).iter()
def get_citation_cursor(self):
return Cursor(self.citation_map, self.get_raw_citation_data).iter()
@ -784,6 +796,11 @@ class DictionaryDb(DbWriteBase, DbReadBase):
return self.media_map[handle].serialize()
return None
def get_raw_tag_data(self, handle):
if handle in self.tag_map:
return self.tag_map[handle].serialize()
return None
def add_person(self, person, trans, set_gid=True):
if not person.handle:
person.handle = create_id()
@ -925,3 +942,14 @@ class DictionaryDb(DbWriteBase, DbReadBase):
def request_rebuild(self):
pass
def copy_from_db(self, db):
"""
A (possibily) implementation-specific method to get data from
db into this database.
"""
for key in db._tables.keys():
cursor = db._tables[key]["cursor_func"]
class_ = db._tables[key]["class_func"]
for (handle, data) in cursor():
map = getattr(self, "%s_map" % key.lower())
map[handle] = class_.create(data)

BIN
gramps/images/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 B

BIN
gramps/images/down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

BIN
gramps/images/next.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
gramps/images/previous.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
gramps/images/up.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,83 @@
/* Input textbox - do not specify a width here, it will be overwritten */
.ffb-input
{
float:left;
color:#000; /* must specify along with watermark color */
height:16px; /* required for webkit browsers (Safari, Chrome) */
}
/* Color of watermark, if present */
.ffb-input.watermark { /* added and removed dynamically */
color:#888; /* must specify along with input color */
}
/* Drop-down arrow, with sprited image */
.ffb-arrow
{
float:left;
width:17px;
height:22px;
background-image:url(../img/sel_win7.gif);
}
.ffb-arrow.out { /* css sprite technique */
background-position:0;
}
.ffb-arrow.over { /* css sprite technique */
background-position:-17px 0;
}
.ffb-arrow.active { /* css sprite technique */
background-position:-34px 0;
}
.ffb-no-results
{
padding:2px;
color:#888;
font-style:italic;
border-bottom:1px solid #828790;
}
/* Container for dropdown contents */
.ffb {
position:absolute; /* this guy's parent div is hard-coded to position:relative */
overflow:hidden;
border-left:1px solid #828790; /* #7B9EBD for Vista */
border-right:1px solid #828790;
background-color:#fff; /* Give it a background-color, so it's not transparent */
}
/* Inner div for dropdown */
.ffb .content {
overflow:auto;
}
.ffb .content .row {
border-bottom:1px solid #828790;
color:#000;
height:20px;
clear:both;
}
.ffb-sel {
cursor:pointer;
cursor:hand;
color:#fff !important;
background-color:#39f;
}
.ffb-match {
font-weight:bold;
color:#000;
}
/* Paging */
.ffb .paging {
vertical-align:middle;
border-bottom:1px solid #828790;
}
.ffb .page, .ffb a.page {
font-size:85%;
padding:2px;
border:solid 1px #339;
background-color:#eef;
margin:2px;
}
.ffb .box {
width:22px;
margin:2px;
}
.ffb .summary {
font-size:85%;
}

View File

@ -1,21 +1,21 @@
# Initialize GRAMPS Django site
update: grampsdb/fixtures/initial_data.json
PYTHONPATH=../../src python manage.py syncdb --noinput
PYTHONPATH=../../src python manage.py createsuperuser --username=admin --email=bugs@gramps-project.org
PYTHONPATH=../../src python manage.py createsuperuser --username=admin1 --email=bugs@gramps-project.org
PYTHONPATH=../.. python manage.py syncdb --noinput
PYTHONPATH=../.. python manage.py createsuperuser --username=admin --email=bugs@gramps-project.org
PYTHONPATH=../.. python manage.py createsuperuser --username=admin1 --email=bugs@gramps-project.org
grampsdb/fixtures/initial_data.json: init.py
PYTHONPATH=../../src python init.py > grampsdb/fixtures/initial_data.json
PYTHONPATH=../.. python init.py > grampsdb/fixtures/initial_data.json
init_gramps:
PYTHONPATH=../../src python init_gramps.py # clear primary and secondary tables
PYTHONPATH=../.. python init_gramps.py # clear primary and secondary tables
run:
PYTHONPATH=../../src python manage.py runserver
PYTHONPATH=../.. python manage.py runserver
sql:
PYTHONPATH=../../src python manage.py sqlall > gramps-sql.sql
PYTHONPATH=../.. python manage.py sqlall > gramps-sql.sql
dump:
echo ".dump" | sqlite3 sqlite.db > gramps-data.sql
@ -24,17 +24,17 @@ load:
sqlite3 sqlite.db < gramps-data.sql
superusers:
PYTHONPATH=../../src python manage.py createsuperuser --username=admin --email=bugs@gramps-project.org
PYTHONPATH=../../src python manage.py createsuperuser --username=admin1 --email=bugs@gramps-project.org
PYTHONPATH=../.. python manage.py createsuperuser --username=admin --email=bugs@gramps-project.org
PYTHONPATH=../.. python manage.py createsuperuser --username=admin1 --email=bugs@gramps-project.org
backup:
PYTHONPATH=../../src python manage.py dumpdata > backup.json
PYTHONPATH=../.. python manage.py dumpdata > backup.json
restore: empty
PYTHONPATH=../../src python manage.py loaddata backup.json
PYTHONPATH=../.. python manage.py loaddata backup.json
initial_data:
PYTHONPATH=../../src python manage.py loaddata grampsdb/fixtures/initial_data.json
PYTHONPATH=../.. python manage.py loaddata grampsdb/fixtures/initial_data.json
docs:
mkdir -p docs

View File

@ -34,6 +34,7 @@ else:
import base64
import time
import re
import gramps
from gramps.gen.lib import (Person, Family, Event, Place, Repository,
Citation, Source, Note, MediaObject, Tag,
Researcher)
@ -106,6 +107,98 @@ class DbDjango(DbWriteBase, DbReadBase):
def __init__(self):
DbReadBase.__init__(self)
DbWriteBase.__init__(self)
self._tables = {
'Person':
{
"handle_func": self.get_person_from_handle,
"gramps_id_func": self.get_person_from_gramps_id,
"class_func": gramps.gen.lib.Person,
"cursor_func": self.get_person_cursor,
"handles_func": self.get_person_handles,
"iter_func": self.iter_people,
},
'Family':
{
"handle_func": self.get_family_from_handle,
"gramps_id_func": self.get_family_from_gramps_id,
"class_func": gramps.gen.lib.Family,
"cursor_func": self.get_family_cursor,
"handles_func": self.get_family_handles,
"iter_func": self.iter_families,
},
'Source':
{
"handle_func": self.get_source_from_handle,
"gramps_id_func": self.get_source_from_gramps_id,
"class_func": gramps.gen.lib.Source,
"cursor_func": self.get_source_cursor,
"handles_func": self.get_source_handles,
"iter_func": self.iter_sources,
},
'Citation':
{
"handle_func": self.get_citation_from_handle,
"gramps_id_func": self.get_citation_from_gramps_id,
"class_func": gramps.gen.lib.Citation,
"cursor_func": self.get_citation_cursor,
"handles_func": self.get_citation_handles,
"iter_func": self.iter_citations,
},
'Event':
{
"handle_func": self.get_event_from_handle,
"gramps_id_func": self.get_event_from_gramps_id,
"class_func": gramps.gen.lib.Event,
"cursor_func": self.get_event_cursor,
"handles_func": self.get_event_handles,
"iter_func": self.iter_events,
},
'Media':
{
"handle_func": self.get_object_from_handle,
"gramps_id_func": self.get_object_from_gramps_id,
"class_func": gramps.gen.lib.MediaObject,
"cursor_func": self.get_media_cursor,
"handles_func": self.get_media_object_handles,
"iter_func": self.iter_media_objects,
},
'Place':
{
"handle_func": self.get_place_from_handle,
"gramps_id_func": self.get_place_from_gramps_id,
"class_func": gramps.gen.lib.Place,
"cursor_func": self.get_place_cursor,
"handles_func": self.get_place_handles,
"iter_func": self.iter_places,
},
'Repository':
{
"handle_func": self.get_repository_from_handle,
"gramps_id_func": self.get_repository_from_gramps_id,
"class_func": gramps.gen.lib.Repository,
"cursor_func": self.get_repository_cursor,
"handles_func": self.get_repository_handles,
"iter_func": self.iter_repositories,
},
'Note':
{
"handle_func": self.get_note_from_handle,
"gramps_id_func": self.get_note_from_gramps_id,
"class_func": gramps.gen.lib.Note,
"cursor_func": self.get_note_cursor,
"handles_func": self.get_note_handles,
"iter_func": self.iter_notes,
},
'Tag':
{
"handle_func": self.get_tag_from_handle,
"gramps_id_func": None,
"class_func": gramps.gen.lib.Tag,
"cursor_func": self.get_tag_cursor,
"handles_func": self.get_tag_handles,
"iter_func": self.iter_tags,
},
}
# skip GEDCOM cross-ref check for now:
self.set_feature("skip-check-xref", True)
self.dji = DjangoInterface()
@ -748,6 +841,55 @@ class DbDjango(DbWriteBase, DbReadBase):
def iter_family_handles(self):
return (family.handle for family in self.dji.Family.all())
def iter_notes(self):
return (self.get_note_from_handle(note.handle)
for note in self.dji.Note.all())
def iter_note_handles(self):
return (note.handle for note in self.dji.Note.all())
def iter_events(self):
return (self.get_event_from_handle(event.handle)
for event in self.dji.Event.all())
def iter_event_handles(self):
return (event.handle for event in self.dji.Event.all())
def iter_places(self):
return (self.get_place_from_handle(place.handle)
for place in self.dji.Place.all())
def iter_place_handles(self):
return (place.handle for place in self.dji.Place.all())
def iter_repositories(self):
return (self.get_repository_from_handle(repository.handle)
for repository in self.dji.Repository.all())
def iter_repository_handles(self):
return (repository.handle for repository in self.dji.Repository.all())
def iter_sources(self):
return (self.get_source_from_handle(source.handle)
for source in self.dji.Source.all())
def iter_source_handles(self):
return (source.handle for source in self.dji.Source.all())
def iter_citations(self):
return (self.get_citation_from_handle(citation.handle)
for citation in self.dji.Citation.all())
def iter_citation_handles(self):
return (citation.handle for citation in self.dji.Citation.all())
def iter_tags(self):
return (self.get_tag_from_handle(tag.handle)
for tag in self.dji.Tag.all())
def iter_tag_handles(self):
return (tag.handle for tag in self.dji.Tag.all())
def get_tag_from_name(self, name):
try:
tag = self.dji.Tag.filter(name=name)
@ -805,7 +947,7 @@ class DbDjango(DbWriteBase, DbReadBase):
def get_family_cursor(self):
return Cursor(self.dji.Family, self.get_raw_family_data).iter()
def get_events_cursor(self):
def get_event_cursor(self):
return Cursor(self.dji.Event, self.get_raw_event_data).iter()
def get_citation_cursor(self):
@ -814,6 +956,18 @@ class DbDjango(DbWriteBase, DbReadBase):
def get_source_cursor(self):
return Cursor(self.dji.Source, self.get_raw_source_data).iter()
def get_note_cursor(self):
return Cursor(self.dji.Note, self.get_raw_note_data).iter()
def get_tag_cursor(self):
return Cursor(self.dji.Tag, self.get_raw_tag_data).iter()
def get_repository_cursor(self):
return Cursor(self.dji.Repository, self.get_raw_repository_data).iter()
def get_media_cursor(self):
return Cursor(self.dji.Media, self.get_raw_object_data).iter()
def has_gramps_id(self, obj_key, gramps_id):
key2table = {
PERSON_KEY: self.dji.Person,
@ -965,6 +1119,24 @@ class DbDjango(DbWriteBase, DbReadBase):
else:
return None
def get_raw_tag_data(self, handle):
try:
return self.dji.get_tag(self.dji.Tag.get(handle=handle))
except:
if handle in self.import_cache:
return self.import_cache[handle].serialize()
else:
return None
def get_raw_event_data(self, handle):
try:
return self.dji.get_event(self.dji.Event.get(handle=handle))
except:
if handle in self.import_cache:
return self.import_cache[handle].serialize()
else:
return None
def add_person(self, person, trans, set_gid=True):
if not person.handle:
person.handle = create_id()
@ -1108,3 +1280,58 @@ class DbDjango(DbWriteBase, DbReadBase):
def set_researcher(self, owner):
pass
def copy_from_db(self, db):
"""
A (possibily) implementation-specific method to get data from
db into this database.
"""
# First we add the primary objects:
for key in db._tables.keys():
cursor = db._tables[key]["cursor_func"]
for (handle, data) in cursor():
if key == "Person":
self.dji.add_person(data)
elif key == "Family":
self.dji.add_family(data)
elif key == "Event":
self.dji.add_event(data)
elif key == "Place":
self.dji.add_place(data)
elif key == "Repository":
self.dji.add_repository(data)
elif key == "Citation":
self.dji.add_citation(data)
elif key == "Source":
self.dji.add_source(data)
elif key == "Note":
self.dji.add_note(data)
elif key == "Media":
self.dji.add_media(data)
elif key == "Tag":
self.dji.add_tag(data)
for key in db._tables.keys():
cursor = db._tables[key]["cursor_func"]
for (handle, data) in cursor():
if key == "Person":
self.dji.add_person_detail(data)
elif key == "Family":
self.dji.add_family_detail(data)
elif key == "Event":
self.dji.add_event_detail(data)
elif key == "Place":
self.dji.add_place_detail(data)
elif key == "Repository":
self.dji.add_repository_detail(data)
elif key == "Citation":
self.dji.add_citation_detail(data)
elif key == "Source":
self.dji.add_source_detail(data)
elif key == "Note":
self.dji.add_note_detail(data)
elif key == "Media":
self.dji.add_media_detail(data)
elif key == "Tag":
self.dji.add_tag_detail(data)
# Next we add the links:
self.dji.update_publics()

View File

@ -228,8 +228,8 @@ CREATE TABLE "auth_user" (
"last_login" datetime NOT NULL,
"date_joined" datetime NOT NULL
);
INSERT INTO "auth_user" VALUES(1,'admin','','','bugs@gramps-project.org','sha1$248cf$71082f5ec314e2706d1cc9e44a0d63b953ba1d08',1,1,1,'2012-07-31 07:58:28.096063','2012-07-31 07:58:28.096063');
INSERT INTO "auth_user" VALUES(2,'admin1','','','bugs@gramps-project.org','sha1$bd368$2e83f9d34578f66402e62b698950adae05f4d6bf',1,1,1,'2012-07-31 07:58:37.492571','2012-07-31 07:58:37.492571');
INSERT INTO "auth_user" VALUES(1,'admin','','','bugs@gramps-project.org','sha1$e6c7c$4b1fb71d557b37a04eecffaf9c61f086b1ca35f5',1,1,1,'2012-08-10 08:16:43.964714','2012-08-10 08:16:43.964714');
INSERT INTO "auth_user" VALUES(2,'admin1','','','bugs@gramps-project.org','sha1$f466d$20b08567aa61bd56d523ee497f215119ffe8c4fa',1,1,1,'2012-08-10 08:16:49.093450','2012-08-10 08:16:49.093450');
CREATE TABLE "auth_message" (
"id" integer NOT NULL PRIMARY KEY,
"user_id" integer NOT NULL REFERENCES "auth_user" ("id"),
@ -648,7 +648,7 @@ CREATE TABLE "grampsdb_config" (
);
INSERT INTO "grampsdb_config" VALUES(1,'sitename','site name of family tree','str','Gramps-Connect');
INSERT INTO "grampsdb_config" VALUES(2,'db_version','database scheme version','str','0.6.1');
INSERT INTO "grampsdb_config" VALUES(3,'db_created','database creation date/time','str','2012-07-31 07:56');
INSERT INTO "grampsdb_config" VALUES(3,'db_created','database creation date/time','str','2012-08-10 08:12');
INSERT INTO "grampsdb_config" VALUES(4,'htmlview.url-handler',NULL,'bool','False');
INSERT INTO "grampsdb_config" VALUES(5,'htmlview.start-url',NULL,'str','http://gramps-project.org');
INSERT INTO "grampsdb_config" VALUES(6,'paths.recent-export-dir',NULL,'str','');

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
from __future__ import print_function
from webapp.grampsdb.models import *
from gramps.webapp.grampsdb.models import *
from django.contrib import admin
class MyAdmin(admin.ModelAdmin):

View File

@ -30,7 +30,7 @@ from django.forms.models import BaseModelFormSet
from django.forms.widgets import TextInput, HiddenInput
# Gramps Modules:
from webapp.grampsdb.models import *
from gramps.webapp.grampsdb.models import *
from gramps.gen.mime import get_type
# Python Modules:
@ -142,7 +142,7 @@ class EventForm(forms.ModelForm):
"place"]
def clean(self):
from webapp.utils import dp
from gramps.webapp.utils import dp
data = super(EventForm, self).clean()
dobj = dp(data.get('text'))
if not dobj.is_valid():
@ -152,8 +152,8 @@ class EventForm(forms.ModelForm):
return data
def save(self, commit=True):
from webapp.utils import dp
from webapp.libdjango import DjangoInterface
from gramps.webapp.utils import dp
from gramps.webapp.libdjango import DjangoInterface
dji = DjangoInterface()
model = super(EventForm, self).save(commit=False)
dobj = dp(self.cleaned_data['text'])
@ -181,7 +181,7 @@ class MediaForm(forms.ModelForm):
"newyear", "calendar", "modifier", "quality", "cache"]
def clean(self):
from webapp.utils import dp
from gramps.webapp.utils import dp
data = super(MediaForm, self).clean()
dobj = dp(data.get('text'))
if not dobj.is_valid():
@ -191,8 +191,8 @@ class MediaForm(forms.ModelForm):
return data
def save(self, commit=True):
from webapp.utils import dp
from webapp.libdjango import DjangoInterface
from gramps.webapp.utils import dp
from gramps.webapp.libdjango import DjangoInterface
dji = DjangoInterface()
model = super(MediaForm, self).save(commit=False)
model.mime = get_type(model.path)
@ -219,7 +219,7 @@ class CitationForm(forms.ModelForm):
"newyear", "calendar", "modifier", "quality", "cache"]
def clean(self):
from webapp.utils import dp
from gramps.webapp.utils import dp
data = super(CitationForm, self).clean()
dobj = dp(data.get('text'))
if not dobj.is_valid():
@ -229,8 +229,8 @@ class CitationForm(forms.ModelForm):
return data
def save(self, commit=True):
from webapp.utils import dp
from webapp.libdjango import DjangoInterface
from gramps.webapp.utils import dp
from gramps.webapp.libdjango import DjangoInterface
dji = DjangoInterface()
model = super(CitationForm, self).save(commit=False)
dobj = dp(self.cleaned_data['text'])

View File

@ -35,7 +35,7 @@ from django.contrib.contenttypes import generic
from gramps.gen.lib.date import Date as GDate, Today
from gramps.gen.utils.id import create_id, create_uid
from webapp.grampsdb.profile import Profile
from gramps.webapp.grampsdb.profile import Profile
#---------------------------------------------------------------------------
#

View File

@ -58,11 +58,11 @@ from django.utils import simplejson
# Gramps Modules
#
#------------------------------------------------------------------------
import webapp
from webapp.utils import _, build_args
from webapp.grampsdb.models import *
from webapp.grampsdb.view import *
from webapp.dbdjango import DbDjango
import gramps.webapp
from gramps.webapp.utils import _, build_args
from gramps.webapp.grampsdb.models import *
from gramps.webapp.grampsdb.view import *
from gramps.webapp.dbdjango import DbDjango
from gramps.cli.user import User
from gramps.gen.const import VERSION_TUPLE
from gramps.gen.utils.svn import get_svn_revision
@ -137,7 +137,8 @@ def logout_page(request):
def make_message(request, message):
if request.user.is_authenticated():
request.user.message_set.create(message = message)
#request.user.message_set.create(message = message)
print("FIXME: message_set:", message)
else:
request.session['message'] = message
@ -188,7 +189,7 @@ def process_report_run(request, handle):
"""
Run a report or export.
"""
from webapp.reports import import_file, export_file, download
from gramps.webapp.reports import import_file, export_file, download
from gramps.cli.plug import run_report
import traceback
db = DbDjango()
@ -444,7 +445,7 @@ def action(request, view, handle, act, add_to=None):
View a particular object given /object/handle (implied view),
/object/handle/action, or /object/add.
"""
from webapp.reports import get_plugin_options
from gramps.webapp.reports import get_plugin_options
# redirect:
rd = None
obj = None

View File

@ -30,7 +30,7 @@ from __future__ import print_function
import time
import os
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
from . import settings
import settings
from gramps.gen.config import config
from gramps.gen.lib.nametype import NameType
@ -46,8 +46,9 @@ from gramps.gen.lib.eventroletype import EventRoleType
from gramps.gen.lib.notetype import NoteType
from gramps.gen.lib.styledtexttagtype import StyledTextTagType
from .grampsdb.models import (GenderType, LdsType, LdsStatus,
NameFormatType, NameOriginType, ThemeType)
from gramps.webapp.grampsdb.models import (GenderType, LdsType, LdsStatus,
NameFormatType, NameOriginType,
ThemeType)
def get_datamap(x):
"""

View File

@ -25,8 +25,8 @@ Clears gramps data
import os
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
from . import settings
import settings
from . import grampsdb.models as dj
from .grampsdb models import models as dj
dj.clear_tables("primary", "secondary", "ref", "system")

View File

@ -49,8 +49,7 @@ from django.db import transaction
# Gramps Modules
#
#------------------------------------------------------------------------
import webapp.grampsdb.models as models
import webapp
import gramps.webapp.grampsdb.models as models
from gramps.gen.lib import Name
from gramps.gen.utils.id import create_id
import collections
@ -1923,7 +1922,12 @@ class DjangoInterface(object):
return public, reason
# FIXME: what about Associations... anything else? Check PrivateProxy
if objref:
obj_ref_list = objref.filter(ref_object=obj)
if hasattr(objref.model, "ref_object"):
obj_ref_list = objref.filter(ref_object=obj)
elif hasattr(objref.model, "citation"):
obj_ref_list = objref.filter(citation=obj)
else:
raise Exception("objref '%s' needs a ref for '%s'" % (objref.model, obj))
for reference in obj_ref_list:
ref_from_class = reference.object_type.model_class()
item = None

View File

@ -30,7 +30,7 @@
#------------------------------------------------------------------------
from django.core.management import execute_manager
try:
from . import settings # Assumed to be in the same directory.
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)

View File

@ -59,8 +59,9 @@ ADMIN_MEDIA_PREFIX = '/gramps-media/'
SECRET_KEY = 'zd@%vslj5sqhx94_8)0hsx*rk9tj3^ly$x+^*tq4bggr&uh$ac'
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.filesystem.Loader', # 1.4
#'django.template.loaders.filesystem.load_template_source',
#'django.template.loaders.app_directories.load_template_source',
)
MIDDLEWARE_CLASSES = (
@ -68,10 +69,10 @@ MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
)
ROOT_URLCONF = 'webapp.urls'
ROOT_URLCONF = 'gramps.webapp.urls'
TEMPLATE_DIRS = (
# Use absolute paths, not relative paths.
@ -79,12 +80,13 @@ TEMPLATE_DIRS = (
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
# "django.core.context_processors.debug",
"django.contrib.auth.context_processors.auth", # 1.4
# "django.core.context_processors.auth",
# "django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"webapp.grampsdb.views.context_processor",
"webapp.context.messages",
"gramps.webapp.grampsdb.views.context_processor",
"gramps.webapp.context.messages",
)
INSTALLED_APPS = (
@ -93,7 +95,7 @@ INSTALLED_APPS = (
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'webapp.grampsdb',
'gramps.webapp.grampsdb',
# 'django_extensions',
# 'debug_toolbar',
)
@ -141,13 +143,3 @@ FORMAT_MODULE_PATH = ""
USE_TZ = True
## End Changes for Django 1.4
# In versions < 2.7 python does not properly copy methods when doing a
# deepcopy. This workaround makes the copy work properly. When Gramps no longer
# supports python 2.6, this workaround can be removed.
import sys
if sys.version_info < (2, 7) :
import copy
import types
def _deepcopy_method(x, memo):
return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class)
copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method

View File

@ -4,21 +4,25 @@
#### $ PYTHONPATH=..:../plugins/lib python -i shell.py
#### >>> Person.objects.all()
import os
pystartup = os.path.expanduser("~/.pystartup")
if os.path.exists(pystartup):
execfile(pystartup)
from django.conf import settings
import webapp.settings as default_settings
import gramps.webapp.settings as default_settings
try:
settings.configure(default_settings)
except RuntimeError:
# already configured; ignore
pass
from webapp.grampsdb.models import *
from webapp.grampsdb.forms import *
from webapp.dbdjango import DbDjango
from webapp.reports import import_file
from webapp.libdjango import DjangoInterface, totime, todate
from .grampsdb.models import *
from .grampsdb.forms import *
from .dbdjango import DbDjango
from .reports import import_file
from .libdjango import DjangoInterface, totime, todate
from gramps.gen.datehandler import displayer, parser
from webapp.utils import StyledNoteFormatter, parse_styled_text
from .utils import StyledNoteFormatter, parse_styled_text
from gramps.gen.lib import StyledText
from gramps.cli.user import User

View File

@ -38,7 +38,7 @@ from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
from webapp.grampsdb.views import *
from gramps.webapp.grampsdb.views import *
urlpatterns = patterns('',
# Specific matches first:

View File

@ -51,10 +51,10 @@ from django.db.models import Q
# Gramps-Connect Modules
#
#------------------------------------------------------------------------
import webapp.grampsdb.models as models
import webapp.grampsdb.forms as forms
from webapp import libdjango
from webapp.dbdjango import DbDjango
import gramps.webapp.grampsdb.models as models
import gramps.webapp.grampsdb.forms as forms
from gramps.webapp import libdjango
from gramps.webapp.dbdjango import DbDjango
#------------------------------------------------------------------------
#
@ -299,8 +299,83 @@ def make_button(text, url, *args):
newargs.append(arg)
if newargs:
url = url % tuple(newargs)
return mark_safe("""<input type="button" value="%s" onclick="document.location.href='%s%s%s'"/>""" %
(text, url, kwargs, last))
if text[0] in "+$-?x" or text in ["x", "^", "v", "<", "<<", ">", ">>"]:
return mark_safe(make_image_button(text, url, kwargs, last))
else:
return mark_safe("""<input type="button" value="%s" onclick="document.location.href='%s%s%s'"/>""" %
(text, url, kwargs, last))
def make_image_button(text, url, kwargs, last):
if text == "x":
button = "x"
text = "Delete row"
elif text == "^":
button = "^"
text = "Move row up"
elif text == "v":
button = "v"
text = "Move row down"
elif text.startswith("+"):
button = "+"
text = text[1:]
elif text.startswith("<"):
button = "<"
text = text[1:]
elif text.startswith("<<"):
button = "<<"
text = text[2:]
elif text.startswith(">"):
button = ">"
text = text[1:]
elif text.startswith(">>"):
button = ">>"
text = text[2:]
elif text.startswith("-"):
button = "x"
text = text[1:]
elif text.startswith("$"):
button = "$"
text = text[1:]
elif text.startswith("?"):
button = "?"
text = text[1:]
elif text.startswith("x"):
button = "cancel"
text = text[1:]
return make_image_button2(button, text, url, kwargs, last)
def make_image_button2(button, text, url, kwargs="", last=""):
if button == "cancel":
filename = "/images/gtk-remove.png"
elif button == "x": # delete
filename = "/images/gtk-remove.png"
elif button == "^": # move up
filename = "/images/up.png"
elif button == "v": # move down
filename = "/images/down.png"
elif button == "<": # prev
filename = "/images/previous.png"
elif button == "<<": # start
filename = "/images/player-start.png"
elif button == ">": # next
filename = "/images/next.png"
elif button == ">>": # end
filename = "/images/player-end.png"
elif button == "+": # add
filename = "/images/add.png"
elif button == "$": # pick, share
filename = "/images/stock_index_24.png"
elif button == "?": # edit
filename = "/images/text-editor.png"
elif button == "add child to existing family":
filename = "/images/scalable/gramps-parents-open.svg"
elif button == "add child to new family":
filename = "/images/scalable/gramps-parents-add.svg"
elif button == "add spouse to existing family":
filename = "/images/scalable/add-parent-existing-family.svg"
elif button == "add spouse to new family":
filename = "/images/scalable/gramps-parents.svg"
return """<img height="22" width="22" alt="%s" title="%s" src="%s" onmouseover="buttonOver(this)" onmouseout="buttonOut(this)" onclick="document.location.href='%s%s%s'" style="background-color: lightgray; border: 1px solid lightgray; border-radius:5px; margin: 0px 1px; padding: 1px;" />""" % (text, text, filename, url, kwargs, last)
def event_table(obj, user, act, url, args):
retval = ""
@ -315,7 +390,7 @@ def event_table(obj, user, act, url, args):
_("Date"),
_("Place"),
_("Role"))
table.column_widths = [10, 20, 10, 7, 20, 23, 10]
table.column_widths = [11, 19, 10, 7, 20, 23, 10]
if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj)
event_ref_list = models.EventRef.objects.filter(
@ -325,7 +400,7 @@ def event_table(obj, user, act, url, args):
links = []
count = 1
for (djevent, event_ref) in event_list:
table.row(Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser and act == "view" else "",
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and act == "view" else "",
djevent.description,
table.db.get_event_from_handle(djevent.handle),
djevent.gramps_id,
@ -336,19 +411,24 @@ def event_table(obj, user, act, url, args):
has_data = True
count += 1
table.links(links)
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and act == "view":
retval += make_button(_("+Add New Event"), (url % args).replace("$act", "add"))
retval += make_button(_("$Add Existing Event"), (url % args).replace("$act", "share"))
else:
retval += """<div style="height: 26px;"></div>""" # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if user.is_superuser and act == "view":
count = 1
retval = retval.replace("{{", """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
retval = retval.replace("}}", """</div>""")
for (djevent, event_ref) in event_list:
item = obj.__class__.__name__.lower()
retval = retval.replace("[[x%d]]" % count, make_button("x", "/%s/%s/remove/eventref/%d" % (item, obj.handle, count)))
retval = retval.replace("[[^%d]]" % count, make_button("^", "/%s/%s/up/eventref/%d" % (item, obj.handle, count)))
retval = retval.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/eventref/%d" % (item, obj.handle, count)))
count += 1
retval += make_button(_("Add New Event"), (url % args).replace("$act", "add"))
retval += make_button(_("Add Existing Event"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -417,11 +497,13 @@ def name_table(obj, user, act, url=None, *args):
(url % name.person.handle) + ("/%s" % name.order)))
has_data = True
table.links(links)
retval += table.get_html()
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("Add Name"), (url % args))
retval += make_button(_("+Add Name"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -434,6 +516,12 @@ def surname_table(obj, user, act, url=None, *args):
cssid = "tab-surnames"
table = Table("surname_table")
table.columns(_("Order"), _("Surname"),)
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("+Add Surname"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
if user.is_authenticated() or obj.public:
try:
name = obj.name_set.filter(order=order)[0]
@ -446,10 +534,6 @@ def surname_table(obj, user, act, url=None, *args):
retval += table.get_html()
else:
retval += "<p id='error'>No such name order = %s</p>" % order
if user.is_superuser and url and act == "view":
retval += make_button(_("Add Surname"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -465,7 +549,7 @@ def citation_table(obj, user, act, url=None, *args):
_("ID"),
_("Confidence"),
_("Page"))
table.column_widths = [10, 10, 50, 30]
table.column_widths = [11, 10, 49, 30]
if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj)
citation_refs = dji.CitationRef.filter(object_type=obj_type,
@ -476,7 +560,7 @@ def citation_table(obj, user, act, url=None, *args):
if citation_ref.citation:
citation = table.db.get_citation_from_handle(
citation_ref.citation.handle)
table.row(Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
citation.gramps_id,
str(citation.confidence),
str(citation.page),
@ -485,8 +569,17 @@ def citation_table(obj, user, act, url=None, *args):
has_data = True
count += 1
table.links(links)
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("+Add New Citation"), (url % args).replace("$act", "add"))
retval += make_button(_("$Add Existing Citation"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if user.is_superuser and url and act == "view":
retval = retval.replace("{{", """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
retval = retval.replace("}}", """</div>""")
count = 1
for citation_ref in citation_refs:
item = obj.__class__.__name__.lower()
@ -494,10 +587,6 @@ def citation_table(obj, user, act, url=None, *args):
retval = retval.replace("[[^%d]]" % count, make_button("^", "/%s/%s/up/citationref/%d" % (item, obj.handle, count)))
retval = retval.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/citationref/%d" % (item, obj.handle, count)))
count += 1
retval += make_button(_("Add New Citation"), (url % args).replace("$act", "add"))
retval += make_button(_("Add Existing Citation"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -514,6 +603,14 @@ def repository_table(obj, user, act, url=None, *args):
_("Call number"),
_("Type"),
)
table.column_widths = [11, 49, 20, 20]
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("+Add New Repository"), (url % args).replace("$act", "add"))
retval += make_button(_("$Add Existing Repository"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
if user.is_authenticated() or obj.public:
obj_type = ContentType.objects.get_for_model(obj)
refs = dji.RepositoryRef.filter(object_type=obj_type,
@ -522,7 +619,7 @@ def repository_table(obj, user, act, url=None, *args):
for repo_ref in refs:
repository = repo_ref.ref_object
table.row(
Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser else "",
Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser else "",
repository.gramps_id,
repository.name,
repo_ref.call_number,
@ -531,6 +628,8 @@ def repository_table(obj, user, act, url=None, *args):
has_data = True
count += 1
text = table.get_html()
text = text.replace("{{", """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
text = text.replace("}}", """</div>""")
count = 1
for repo_ref in refs:
item = obj.__class__.__name__.lower()
@ -539,11 +638,6 @@ def repository_table(obj, user, act, url=None, *args):
text = text.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/repositoryref/%d" % (item, obj.handle, count)))
count += 1
retval += text
if user.is_superuser and url and act == "view":
retval += make_button(_("Add New Repository"), (url % args).replace("$act", "add"))
retval += make_button(_("Add Existing Repository"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -567,12 +661,14 @@ def note_table(obj, user, act, url=None, *args):
str(note.note_type),
note.text[:50])
has_data = True
retval += table.get_html()
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("Add New Note"), (url % args).replace("$act", "add"))
retval += make_button(_("Add Existing Note"), (url % args).replace("$act", "share"))
retval += make_button(_("+Add New Note"), (url % args).replace("$act", "add"))
retval += make_button(_("$Add Existing Note"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -587,6 +683,14 @@ def data_table(obj, user, act, url=None, *args):
_("Type"),
_("Value"),
)
table.column_widths = [11, 39, 50]
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
# /data/$act/citation/%s
retval += make_button(_("+Add Data"), (url.replace("$act", "add") % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
if user.is_authenticated() or obj.public:
item_class = obj.__class__.__name__.lower()
if item_class == "citation":
@ -600,13 +704,15 @@ def data_table(obj, user, act, url=None, *args):
elif item_class == "source":
ref_obj = ref.source
table.row(
Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser else "",
Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser else "",
ref_obj.key,
ref_obj.value,
)
has_data = True
count += 1
text = table.get_html()
text = text.replace("{{", """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
text = text.replace("}}", """</div>""")
count = 1
for repo_ref in refs:
text = text.replace("[[x%d]]" % count, make_button("x", "/%s/%s/remove/datamap/%d" % (item_class, obj.handle, count)))
@ -614,11 +720,6 @@ def data_table(obj, user, act, url=None, *args):
text = text.replace("[[v%d]]" % count, make_button("v", "/%s/%s/down/datamap/%d" % (item_class, obj.handle, count)))
count += 1
retval += text
if user.is_superuser and url and act == "view":
# /data/$act/citation/%s
retval += make_button(_("Add Data"), (url.replace("$act", "add") % args))
else:
retval += nbsp("") # to keep tabs same height
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -639,11 +740,13 @@ def attribute_table(obj, user, act, url=None, *args):
table.row(attribute.attribute_type.name,
attribute.value)
has_data = True
retval += table.get_html()
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("Add Attribute"), (url % args))
retval += make_button(_("+Add Attribute"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -668,11 +771,13 @@ def address_table(obj, user, act, url=None, *args):
location.state,
location.country)
has_data = True
retval += table.get_html()
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("Add Address"), (url % args))
retval += make_button(_("+Add Address"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -697,12 +802,14 @@ def media_table(obj, user, act, url=None, *args):
str(media_ref.ref_object.desc),
media_ref.ref_object.path)
has_data = True
retval += table.get_html()
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("Add New Media"), (url % args).replace("$act", "add"))
retval += make_button(_("Add Existing Media"), (url % args).replace("$act", "share"))
retval += make_button(_("+Add New Media"), (url % args).replace("$act", "add"))
retval += make_button(_("$Add Existing Media"), (url % args).replace("$act", "share"))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -722,11 +829,13 @@ def internet_table(obj, user, act, url=None, *args):
url_obj.path,
url_obj.desc)
has_data = True
retval += table.get_html()
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("Add Internet"), (str(url) % args))
retval += make_button(_("+Add Internet"), (str(url) % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -739,6 +848,12 @@ def association_table(obj, user, act, url=None, *args):
table.columns(_("Name"),
_("ID"),
_("Association"))
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("+Add Association"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
if user.is_authenticated() or obj.public:
person = table.db.get_person_from_handle(obj.handle)
if person:
@ -746,7 +861,7 @@ def association_table(obj, user, act, url=None, *args):
count = 1
associations = person.get_person_ref_list()
for association in associations: # PersonRef
table.row(Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
association.ref_object.get_primary_name(),
association.ref_object.gramps_id,
association.description,
@ -756,16 +871,14 @@ def association_table(obj, user, act, url=None, *args):
count += 1
table.links(links)
text = table.get_html()
text = text.replace("{{", """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
text = text.replace("}}", """</div>""")
count = 1
for association in associations: # PersonRef
text = text.replace("[[x%d]]" % count, make_button("x", "/person/%s/remove/association/%d" % (obj.handle, count)))
text = text.replace("[[^%d]]" % count, make_button("^", "/person/%s/up/association/%d" % (obj.handle, count)))
text = text.replace("[[v%d]]" % count, make_button("v", "/person/%s/down/association/%d" % (obj.handle, count)))
retval += text
if user.is_superuser and url and act == "view":
retval += make_button(_("Add Association"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -794,11 +907,13 @@ def location_table(obj, user, act, url=None, *args):
location.state,
location.country)
has_data = True
retval += table.get_html()
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("Add Address"), (url % args))
retval += make_button(_("+Add Address"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -823,17 +938,19 @@ def lds_table(obj, user, act, url=None, *args):
lds.temple,
get_title(lds.place))
has_data = True
retval += table.get_html()
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
retval += make_button(_("Add LDS"), (url % args))
retval += make_button(_("+Add LDS"), (url % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += table.get_html()
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
def person_reference_table(obj, user, act):
retval = """<div style="overflow: auto; height:%spx;">""" % TAB_HEIGHT
retval = ""
has_data = False
cssid = "tab-references"
text1 = ""
@ -844,26 +961,28 @@ def person_reference_table(obj, user, act):
_("ID"),
_("Reference"),
)
table1.column_widths = [10, 10, 82]
table1.column_widths = [11, 10, 79]
table2 = Table("person_reference_table", style="background-color: #f4f0ec;")
table2.columns(
"As Child",
_("ID"),
_("Reference"),
)
table2.column_widths = [10, 10, 82]
table2.column_widths = [11, 10, 79]
if (user.is_authenticated() or obj.public) and act != "add":
count = 1
for through in models.MyFamilies.objects.filter(person=obj).order_by("order"):
reference = through.family
table1.row(
Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser else "",
Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser else "",
reference.gramps_id,
reference,
)
has_data = True
count += 1
text1 += table1.get_html()
text1 = text1.replace("{{", """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
text1 = text1.replace("}}", """</div>""")
count = 1
for through in models.MyFamilies.objects.filter(person=obj).order_by("order"):
reference = through.family
@ -876,13 +995,15 @@ def person_reference_table(obj, user, act):
for through in models.MyParentFamilies.objects.filter(person=obj).order_by("order"):
reference = through.family
table2.row(
Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser else "",
Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser else "",
reference.gramps_id,
reference,
)
has_data = True
count += 1
text2 += table2.get_html()
text2 = text2.replace("{{", """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
text2 = text2.replace("}}", """</div>""")
count = 1
for through in models.MyParentFamilies.objects.filter(person=obj).order_by("order"):
reference = through.family
@ -891,15 +1012,23 @@ def person_reference_table(obj, user, act):
text2 = text2.replace("[[v%d]]" % count, make_button("v", "/person/%s/down/parentfamily/%d" % (obj.handle, count)))
count += 1
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
retval += make_image_button2("add spouse to new family",
_("Add as Spouse to New Family"),
"/family/add/spouse/%s" % obj.handle)
retval += make_image_button2("add spouse to existing family",
_("Add as Spouse to Existing Family"),
"/family/share/spouse/%s" % obj.handle)
retval += "&nbsp;"
retval += make_image_button2("add child to new family",
_("Add as Child to New Family"),
"/family/add/child/%s" % obj.handle)
retval += make_image_button2("add child to existing family",
_("Add as Child to Existing Family"),
"/family/share/child/%s" % obj.handle)
retval += """</div>"""
retval += """<div style="overflow: auto; height:%spx;">""" % TAB_HEIGHT
retval += text1 + text2 + "</div>"
retval += make_button(_("Add as Spouse to New Family"),
"/family/add/spouse/%s" % obj.handle)
retval += make_button(_("Add as Spouse to Existing Family"),
"/family/share/spouse/%s" % obj.handle)
retval += make_button(_("Add as Child to New Family"),
"/family/add/child/%s" % obj.handle)
retval += make_button(_("Add as Child to Existing Family"),
"/family/share/child/%s" % obj.handle)
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -1121,7 +1250,7 @@ def children_table(obj, user, act, url=None, *args):
_("Maternal"),
_("Birth Date"),
)
table.column_widths = [10, 3, 8, 30, 8, 8, 8, 25]
table.column_widths = [11, 5, 10, 29, 8, 8, 10, 19]
family = obj
obj_type = ContentType.objects.get_for_model(family)
@ -1132,7 +1261,7 @@ def children_table(obj, user, act, url=None, *args):
for childref in childrefs:
child = childref.ref_object
if user.is_authenticated() or obj.public:
table.row(Link("[[x%d]][[^%d]][[v%d]]" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
str(count),
"[%s]" % child.gramps_id,
render_name(child, user),
@ -1161,18 +1290,23 @@ def children_table(obj, user, act, url=None, *args):
has_data = True
count += 1
table.links(links)
retval += table.get_html()
text = table.get_html()
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
if user.is_superuser and url and act == "view":
text = text.replace("{{", """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
text = text.replace("}}", """</div>""")
count = 1
for childref in childrefs:
retval = retval.replace("[[x%d]]" % count, make_button("x", "/family/%s/remove/child/%d" % (family.handle, count)))
retval = retval.replace("[[^%d]]" % count, make_button("^", "/family/%s/up/child/%d" % (family.handle, count)))
retval = retval.replace("[[v%d]]" % count, make_button("v", "/family/%s/down/child/%d" % (family.handle, count)))
text = text.replace("[[x%d]]" % count, make_button("x", "/family/%s/remove/child/%d" % (family.handle, count)))
text = text.replace("[[^%d]]" % count, make_button("^", "/family/%s/up/child/%d" % (family.handle, count)))
text = text.replace("[[v%d]]" % count, make_button("v", "/family/%s/down/child/%d" % (family.handle, count)))
count += 1
retval += make_button(_("Add New Person as Child"), (url.replace("$act", "add") % args))
retval += make_button(_("Add Existing Person as Child"), (url.replace("$act", "share") % args))
retval += make_button(_("+Add New Person as Child"), (url.replace("$act", "add") % args))
retval += make_button(_("$Add Existing Person as Child"), (url.replace("$act", "share") % args))
else:
retval += nbsp("") # to keep tabs same height
retval += """</div>"""
retval += text
if has_data:
retval += """ <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
return retval
@ -1341,9 +1475,9 @@ def update_last_changed(obj, user):
register_plugins()
# works after registering plugins:
from htmldoc import HtmlDoc
from libhtmlbackend import HtmlBackend, DocBackend, process_spaces
from libhtml import Html
from gramps.plugins.docgen.htmldoc import HtmlDoc
from gramps.plugins.lib.libhtmlbackend import HtmlBackend, DocBackend, process_spaces
from gramps.plugins.lib.libhtml import Html
class WebAppBackend(HtmlBackend):
SUPPORTED_MARKUP = [