Removed webapp to django-webapp project

This commit is contained in:
Doug Blank 2016-01-06 15:24:27 -05:00
parent b39fd5b634
commit 7aa7f26bbb
47 changed files with 6 additions and 13739 deletions

View File

@ -21,9 +21,6 @@ install:
# $TRAVIS_BUILD_DIR is set to the location of the cloned repository:
# for example: /home/travis/build/gramps-project/gramps
- python3 setup.py build
- cd gramps/webapp
- make create
- cd ../..
#before_script:
# - sudo Xvfb :99 -ac &
@ -31,4 +28,4 @@ install:
script:
- mkdir -p ~/.gramps/grampsdb/
- DJANGO_SETTINGS_MODULE=gramps.webapp.default_settings nosetests3 --exclude=TestcaseGenerator --exclude=vcard --exclude=merge_ref_test gramps
- nosetests3 --exclude=TestcaseGenerator --exclude=vcard --exclude=merge_ref_test gramps

View File

@ -29,4 +29,3 @@ global-exclude *.pyo
# Remove directories which should not be included in the distribution
prune gramps/guiQML
#prune gramps/webapp

View File

@ -1,76 +0,0 @@
# Initialize GRAMPS Django site
PYTHON=GRAMPS_RESOURCES=../.. PYTHONPATH=../.. python3
update: grampsdb/fixtures/initial_data.json
$(PYTHON) manage.py syncdb --noinput
$(PYTHON) manage.py createsuperuser --username=admin --email=bugs@gramps-project.org
$(PYTHON) manage.py createsuperuser --username=admin1 --email=bugs@gramps-project.org
create: grampsdb/fixtures/initial_data.json
$(PYTHON) manage.py syncdb --noinput
grampsdb/fixtures/initial_data.json: init.py
mkdir -p grampsdb/fixtures
$(PYTHON) init.py > grampsdb/fixtures/initial_data.json
init_gramps:
$(PYTHON) init_gramps.py # clear primary and secondary tables
run:
$(PYTHON) manage.py runserver
sql:
$(PYTHON) manage.py sqlall > gramps-sql.sql
dump:
echo ".dump" | sqlite3 sqlite.db > gramps-data.sql
load:
sqlite3 sqlite.db < gramps-data.sql
superusers:
$(PYTHON) manage.py createsuperuser --username=admin --email=bugs@gramps-project.org
$(PYTHON) manage.py createsuperuser --username=admin1 --email=bugs@gramps-project.org
backup:
$(PYTHON) manage.py dumpdata > backup.json
restore: empty
$(PYTHON) manage.py loaddata backup.json
initial_data:
$(PYTHON) manage.py loaddata grampsdb/fixtures/initial_data.json
docs:
mkdir -p docs
$(PYTHON) graph_models grampsdb -i Person,Family,Source,Event,Repository,Place,Media,Note -o docs/primary-tables.png
$(PYTHON) graph_models grampsdb -i Note -o docs/note-table.png
$(PYTHON) graph_models grampsdb -i Media -o docs/media-table.png
$(PYTHON) graph_models grampsdb -i Place -o docs/place-table.png
$(PYTHON) graph_models grampsdb -i Repository -o docs/repository-table.png
$(PYTHON) graph_models grampsdb -i Event -o docs/event-table.png
$(PYTHON) graph_models grampsdb -i Source -o docs/source-table.png
$(PYTHON) graph_models grampsdb -i Family -o docs/family-table.png
$(PYTHON) graph_models grampsdb -i Person -o docs/person-table.png
$(PYTHON) graph_models grampsdb -o docs/all-tables.png
$(PYTHON) graph_models grampsdb -i Attribute,Datamap,Name,Lds,Tag,Address,Location,Url -o docs/secondary-tables.png
$(PYTHON) graph_models grampsdb -i Person,Family,Source,Event,Repository,Place,Media,Note,Attribute,Datamap,Name,Lds,Tag,Address,Location,Url -o docs/prim-sec-tables.png
$(PYTHON) graph_models grampsdb -i Person,Family,Source,Event,Repository,Place,Media,Note,Attribute,Datamap,Name,Lds,Tag,Address,Location,Url -o docs/prim-sec-tables.png
$(PYTHON) graph_models grampsdb -i Person,Family,Source,Event,Repository,Place,Media,Note,Attribute,Datamap,Name,Lds,Tag,Address,Location,Url,NoteRef,SourceRef,EventRef,RepositoryRef,PersonRef,ChildRef,MediaRef -o docs/prim-sec-ref-tables.png
make-empty:
echo ".dump" | sqlite3 sqlite.db > empty.sql
empty:
rm -f sqlite.db
sqlite3 sqlite.db < empty.sql
example:
rm -f sqlite.db
sqlite3 sqlite.db < example.sql
clean:
rm -f sqlite.db
rm -f *~ *.pyc *.pyo
rm -f grampsdb/fixtures/initial_data.json

View File

@ -1,114 +0,0 @@
**UNSTABLE** package for testing.
This webapp, is a web-based application that runs in your browser, and requires a server.
Many Gramps users would like to collaborate or share their genealogy data on the web.
The main focus of this Gramps-based webapp is collaboration, allow users to easily move their genealogy data to the web to be seen, and edited with proper login and permissions, in a live, collaborative environment.
A prototype is on-line at http://gramps-connect.org/
**Requires**
Django (version 1.7 supported until October 2015) (version 1.8 LTS supported until April 2018) ( https://www.djangoproject.com/ )
**Webapp**
- 'gramps-webapp' packages are in progress...
For **Testing only**.
See https://www.gramps-project.org/wiki/index.php?title=Gramps-Connect for more details.
**Some commands**
$ cd /usr/lib/python3.4/dist-packages/gramps/webapp
$ python manage.py help
$ sudo make
# Initialize Gramps Django site
PYTHON=GRAMPS_RESOURCES=../.. PYTHONPATH=../.. python3.4
- update: grampsdb/fixtures/initial_data.json
$(PYTHON) manage.py syncdb --noinput
$(PYTHON) manage.py createsuperuser --username=admin --email=bugs@gramps-project.org
$(PYTHON) manage.py createsuperuser --username=admin1 --email=bugs@gramps-project.org
- grampsdb/fixtures/initial_data.json: init.py
mkdir -p grampsdb/fixtures
$(PYTHON) init.py > grampsdb/fixtures/initial_data.json
- init_gramps:
$(PYTHON) init_gramps.py # clear primary and secondary tables
- run:
$(PYTHON) manage.py runserver
- sql:
$(PYTHON) manage.py sqlall > gramps-sql.sql
- dump:
echo ".dump" | sqlite3 sqlite.db > gramps-data.sql
- load:
sqlite3 sqlite.db < gramps-data.sql
- superusers:
$(PYTHON) manage.py createsuperuser --username=admin --email=bugs@gramps-project.org
$(PYTHON) manage.py createsuperuser --username=admin1 --email=bugs@gramps-project.org
- backup:
$(PYTHON) manage.py dumpdata > backup.json
- restore: empty
$(PYTHON) manage.py loaddata backup.json
- initial_data:
$(PYTHON) manage.py loaddata grampsdb/fixtures/initial_data.json
- docs:
mkdir -p docs
$(PYTHON) graph_models grampsdb -i Person,Family,Source,Event,Repository,Place,Media,Note -o docs/primary-tables.png
$(PYTHON) graph_models grampsdb -i Note -o docs/note-table.png
$(PYTHON) graph_models grampsdb -i Media -o docs/media-table.png
$(PYTHON) graph_models grampsdb -i Place -o docs/place-table.png
$(PYTHON) graph_models grampsdb -i Repository -o docs/repository-table.png
$(PYTHON) graph_models grampsdb -i Event -o docs/event-table.png
$(PYTHON) graph_models grampsdb -i Source -o docs/source-table.png
$(PYTHON) graph_models grampsdb -i Family -o docs/family-table.png
$(PYTHON) graph_models grampsdb -i Person -o docs/person-table.png
$(PYTHON) graph_models grampsdb -o docs/all-tables.png
$(PYTHON) graph_models grampsdb -i Attribute,Datamap,Name,Lds,Tag,Address,Location,Url -o docs/secondary-tables.png
$(PYTHON) graph_models grampsdb -i Person,Family,Source,Event,Repository,Place,Media,Note,Attribute,Datamap,Name,Lds,Tag,Address,Location,Url -o docs/prim-sec-tables.png
$(PYTHON) graph_models grampsdb -i Person,Family,Source,Event,Repository,Place,Media,Note,Attribute,Datamap,Name,Lds,Tag,Address,Location,Url -o docs/prim-sec-tables.png
$(PYTHON) graph_models grampsdb -i Person,Family,Source,Event,Repository,Place,Media,Note,Attribute,Datamap,Name,Lds,Tag,Address,Location,Url,NoteRef,SourceRef,EventRef,RepositoryRef,PersonRef,ChildRef,MediaRef -o docs/prim-sec-ref-tables.png
- make-empty:
echo ".dump" | sqlite3 sqlite.db > empty.sql
- empty:
rm -f sqlite.db
sqlite3 sqlite.db < empty.sql
- example:
rm -f sqlite.db
sqlite3 sqlite.db < example.sql
- clean:
rm -f sqlite.db
rm -f *~ *.pyc *.pyo
rm -f grampsdb/fixtures/initial_data.json

View File

@ -1,47 +0,0 @@
import urllib2
import urllib
import logging
LOG = logging.getLogger(".web")
PATH_TO_LOGIN = "login/"
def login(base_address, username=None, password=None):
# fetch the login page in order to get the csrf token
cookieHandler = urllib2.HTTPCookieProcessor()
opener = urllib2.build_opener(urllib2.HTTPSHandler(), cookieHandler)
urllib2.install_opener(opener)
login_url = base_address + PATH_TO_LOGIN
LOG.info("login_url: " + login_url)
login_page = opener.open(login_url)
# attempt to get the csrf token from the cookie jar
csrf_cookie = None
for cookie in cookieHandler.cookiejar:
if cookie.name == 'csrftoken':
csrf_cookie = cookie
break
if not cookie:
raise IOError("No csrf cookie found")
LOG.info( "found csrf cookie: " + str(csrf_cookie))
LOG.info( "csrf_token = %s" % csrf_cookie.value)
# login using the usr, pwd, and csrf token
login_data = urllib.urlencode(dict(
username=username, password=password,
csrfmiddlewaretoken=csrf_cookie.value))
LOG.info("login_data: %s" % login_data)
LOG.info("login_url: %s" % login_url)
req = urllib2.Request(login_url, login_data)
req.add_header('Referer', login_url)
response = urllib2.urlopen(req)
# <--- 403: FORBIDDEN here
LOG.info('response url:\n' + str(response.geturl()) + '\n')
LOG.info('response info:\n' + str(response.info()) + '\n')
# should redirect to the welcome page here, if back at log in - refused
url = response.geturl()
LOG.info("url:", url)
LOG.info("login_url:", login_url)
if url == login_url:
return None
LOG.info('\t%s is logged in' % username)
# save the cookies/opener for further actions
return opener

View File

@ -1,49 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from urllib.request import (Request, urlopen, HTTPCookieProcessor,
build_opener, install_opener)
from urllib.parse import urlencode
class Connection(object):
"""
>>> conn = Connection()
>>> response = conn.login("http://blankfamily.us/login/", "username", "password")
"""
def login(self, login_url, username, password):
cookies = HTTPCookieProcessor()
opener = build_opener(cookies)
install_opener(opener)
opener.open(login_url)
try:
self.token = [x.value for x in cookies.cookiejar if x.name == 'csrftoken'][0]
except IndexError:
return Exception("no csrftoken")
params = dict(username=username,
password=password,
next="/",
csrfmiddlewaretoken=self.token,
)
login_data = urlencode(params)
request = Request(login_url, login_data)
response = urlopen(request)
if response.geturl() == login_url:
raise Exception("Invalid password")
return response

View File

@ -1,29 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
def messages(request):
messages = {}
if 'message' in request.session:
message_type = request.session.get('message_type', 'error')
messages = {'message': request.session['message'],
'message_type': message_type}
del request.session['message']
if 'message_type' in request.session:
del request.session['message_type']
return messages

View File

@ -1,175 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Django settings for gramps project. """
# Need to be able to import Gramps files from here.
import os
if not 'GRAMPS_RESOURCES' in os.environ:
os.environ['GRAMPS_RESOURCES'] = os.path.dirname(os.path.abspath("../.."))
from gramps.gen.const import DATA_DIR, WEB_DIR
DEBUG = True
TEMPLATE_DEBUG = DEBUG
INTERNAL_IPS = ('127.0.0.1',)
ADMINS = (
('admin', 'your_email@domain.com'),
)
MANAGERS = ADMINS
DATABASE_ROUTERS = []
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(WEB_DIR, 'sqlite.db'),
}
}
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = os.path.join(WEB_DIR, 'sqlite.db')
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
TIME_ZONE = 'America/New_York'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
MEDIA_ROOT = ''
MEDIA_URL = ''
ADMIN_MEDIA_PREFIX = '/gramps-media/'
SECRET_KEY = 'zd@%vslj5sqhx94_8)0hsx*rk9tj3^ly$x+^*tq4bggr&uh$ac'
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader', # 1.4
'django.template.loaders.app_directories.Loader', # 1.4
#'django.template.loaders.filesystem.load_template_source',
#'django.template.loaders.app_directories.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
)
ROOT_URLCONF = 'gramps.webapp.urls'
STATIC_URL = '/static/' # 1.4
TEMPLATE_DIRS = (
# Use absolute paths, not relative paths.
os.path.join(DATA_DIR, "templates"),
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth", # 1.4
"django.contrib.messages.context_processors.messages", # 1.4
# "django.core.context_processors.auth",
# "django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"gramps.webapp.grampsdb.views.context_processor",
"gramps.webapp.context.messages",
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
'django.contrib.messages', # 1.4
'django.contrib.sites',
'django.contrib.admin',
'gramps.webapp.grampsdb',
# 'django_extensions',
# 'debug_toolbar',
)
DEBUG_TOOLBAR_PANELS = (
'debug_toolbar.panels.version.VersionDebugPanel',
'debug_toolbar.panels.timer.TimerDebugPanel',
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
'debug_toolbar.panels.headers.HeaderDebugPanel',
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.template.TemplateDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.signals.SignalDebugPanel',
'debug_toolbar.panels.logger.LoggingPanel',
)
def custom_show_toolbar(request):
return True # Always show toolbar, for example purposes only.
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
# 'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
# 'EXTRA_SIGNALS': ['myproject.signals.MySignal'],
'HIDE_DJANGO_SQL': False,
}
AUTH_PROFILE_MODULE = "grampsdb.Profile"
# Had to add these to use settings.configure():
DATABASE_OPTIONS = ''
URL_VALIDATOR_USER_AGENT = ''
DEFAULT_INDEX_TABLESPACE = ''
DEFAULT_TABLESPACE = ''
CACHE_BACKEND = 'locmem://'
TRANSACTIONS_MANAGED = False
LOCALE_PATHS = tuple()
# Changes for Django 1.3:
USE_L10N = True
FORMAT_MODULE_PATH = ""
## End Changes for Django 1.3
# Changes for Django 1.4:
USE_TZ = False
## End Changes for Django 1.4
# Changes for Django 1.5:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
}
}
DEFAULT_CHARSET = "utf-8"
## End Changes for Django 1.5
## Changes for Django 1.5.4:
LOGGING_CONFIG = None
AUTH_USER_MODEL = 'auth.User'
## End Changes for Django 1.5.4
LOGIN_URL = "/login/"
LOGOUT_URL = "/logout"
LOGIN_REDIRECT_URL = "/"
## Changes for Django 1.6:
LOGGING = None
## Changes for Django 1.7.1:
ABSOLUTE_URL_OVERRIDES = {}
TEST_RUNNER = 'django.test.runner.DiscoverRunner'

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# webapp/grampsdb/admin.py
from gramps.webapp.grampsdb.models import *
from django.contrib import admin
## FIXME: this no longer works in Django 1.5
class MyAdmin(admin.ModelAdmin):
def change_view(self, request, object_id, extra_context=None):
result = super(MyAdmin, self).change_view(request, object_id, extra_context)
if '_addanother' not in request.POST and '_continue' not in request.POST:
result['Location'] = "/"
return result
for type_name in get_tables("all"):
admin.site.register(type_name[1], admin.ModelAdmin)
admin.site.register(Profile, admin.ModelAdmin)

View File

@ -1,306 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# webapp/grampsdb/forms.py
# forms.py forms for Django web project
# Django Modules:
from django import forms
from django.forms.models import inlineformset_factory
from django.forms.models import BaseModelFormSet
from django.forms.widgets import TextInput, HiddenInput
# Gramps Modules:
from gramps.webapp.grampsdb.models import *
from gramps.gen.mime import get_type
# Python Modules:
import datetime
class PersonForm(forms.ModelForm):
class Meta:
model = Person
exclude = ["death", "birth", "handle", "birth_ref_index",
"death_ref_index", "families", "parent_families",
"cache"]
def save(self, *args, **kwargs):
self.instance.save_cache_q = kwargs.pop("save_cache", True)
return super().save(*args, **kwargs)
class NameForm(forms.ModelForm):
class Meta:
model = Name
# Exclude these, so they don't get checked:
exclude = ["order", "calendar", "modifier",
"quality",
#"quality_estimated", "quality_calculated",
#"quality_interpreted",
"year1", "day1", "month1",
"sortval", "newyear", "person"]
# Add these because they are TextFields, which render as
# Textareas:
first_name = forms.CharField(label="Given",
required=False,
widget=TextInput(attrs={'size':'60'}))
title = forms.CharField(required=False,
widget=TextInput(attrs={'size':'15'}))
call = forms.CharField(label="Call",
required=False,
widget=TextInput(attrs={'size':'15'}))
nick = forms.CharField(label="Nick",
required=False,
widget=TextInput(attrs={'size':'15'}))
group_as = forms.CharField(label="Group as",
required=False,
widget=TextInput(attrs={'size':'30'}))
suffix = forms.CharField(required=False,
initial=' suffix ',
widget=TextInput(attrs={'size':'15',
'style': 'font-style: italic; color: gray; ',
'onFocus': """if (this.value == ' suffix ') {
this.value = '';
}
this.style.color = "black";
this.style.fontStyle = 'normal';
""",
'onBlur': """if (this.value == '') {
this.value = ' suffix ';
this.style.color = "gray";
this.style.fontStyle = 'italic';
}
"""}))
class NameFormFromPerson(NameForm):
class Meta:
model = Name
# Exclude these, so they don't get checked:
# Excludes sort_as and display_as
exclude = ["order", "calendar", "modifier",
"quality",
#"quality_estimated", "quality_calculated",
#"quality_interpreted",
"year1", "day1", "month1",
"sortval", "newyear", "person",
"group_as", "sort_as", "display_as"]
class SurnameForm(forms.ModelForm):
class Meta:
model = Surname
exclude = ['name', 'order']
surname = forms.CharField(label="Surname",
required=False,
widget=TextInput(attrs={'size':'30'}))
connector = forms.CharField(label="Connector",
required=False,
widget=TextInput(attrs={'size':'30'}))
prefix = forms.CharField(label="Prefix",
required=False,
initial=' prefix ',
widget=TextInput(attrs={'size':'15',
'style': 'font-style: italic; color: gray; ',
'onFocus': """if (this.value == ' prefix ') {
this.value = '';
}
this.style.color = "black";
this.style.fontStyle = 'normal';
""",
'onBlur': """if (this.value == '') {
this.value = ' prefix ';
this.style.color = "gray";
this.style.fontStyle = 'italic';
}
"""}))
class FamilyForm(forms.ModelForm):
class Meta:
model = Family
exclude = ["handle", "cache", "mother", "father"]
class EventForm(forms.ModelForm):
class Meta:
model = Event
exclude = ["handle", "sortval", "month1", "year1", "day1",
"newyear", "calendar", "modifier", "quality", "cache",
"place"]
def clean(self):
from gramps.webapp.utils import dp
data = super(EventForm, self).clean()
dobj = dp(data.get('text'))
if not dobj.is_valid():
msg = "Invalid date format"
self._errors["date"] = self.error_class([msg])
del data["text"]
return data
def save(self, commit=True):
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'])
dji.add_date(model, dobj.serialize())
if commit:
model.save()
return model
text = forms.CharField(label="Date",
required=False,
widget=TextInput(attrs={'size':'45'}))
class NoteForm(forms.ModelForm):
class Meta:
model = Note
exclude = ["handle", "text"]
notetext = forms.CharField(label="Text",
widget=forms.widgets.Textarea(attrs={'rows':'10', 'cols': '80', 'class':'wysiwyg'}))
class MediaForm(forms.ModelForm):
class Meta:
model = Media
exclude = ["handle", "sortval", "month1", "year1", "day1",
"newyear", "calendar", "modifier", "quality", "cache"]
def clean(self):
from gramps.webapp.utils import dp
data = super(MediaForm, self).clean()
dobj = dp(data.get('text'))
if not dobj.is_valid():
msg = "Invalid date format"
self._errors["date"] = self.error_class([msg])
del data["text"]
return data
def save(self, commit=True):
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)
dobj = dp(self.cleaned_data['text'])
dji.add_date(model, dobj.serialize())
if commit:
model.save()
return model
text = forms.CharField(label="Date",
required=False,
widget=TextInput(attrs={'size':'70'}))
desc = forms.CharField(label="Title",
required=False,
widget=TextInput(attrs={'size':'70'}))
path = forms.CharField(label="Path",
required=False,
widget=TextInput(attrs={'size':'70'}))
class CitationForm(forms.ModelForm):
class Meta:
model = Citation
exclude = ["handle", "sortval", "month1", "year1", "day1",
"newyear", "calendar", "modifier", "quality", "cache"]
def clean(self):
from gramps.webapp.utils import dp
data = super(CitationForm, self).clean()
dobj = dp(data.get('text'))
if not dobj.is_valid():
msg = "Invalid date format"
self._errors["date"] = self.error_class([msg])
del data["text"]
return data
def save(self, commit=True):
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'])
dji.add_date(model, dobj.serialize())
if commit:
model.save()
return model
text = forms.CharField(label="Date",
required=False,
widget=TextInput(attrs={'size':'70'}))
class SourceForm(forms.ModelForm):
class Meta:
model = Source
exclude = ["handle", "cache"]
class PlaceForm(forms.ModelForm):
class Meta:
model = Place
exclude = ["handle", "cache"]
title = forms.CharField(label="Title",
required=False,
widget=TextInput(attrs={'size':'70'}))
long = forms.CharField(label="Longitude",
required=False,
widget=TextInput(attrs={'size':'70'}))
lat = forms.CharField(label="Latitude",
required=False,
widget=TextInput(attrs={'size':'70'}))
class RepositoryForm(forms.ModelForm):
class Meta:
model = Repository
exclude = ["handle", "cache"]
name = forms.CharField(label="Name",
required=False,
widget=TextInput(attrs={'size':'70'}))
class TagForm(forms.ModelForm):
class Meta:
model = Tag
exclude = ["handle"]
name = forms.CharField(label="Name",
required=False,
widget=TextInput(attrs={'size':'70'}))
class EventRefForm(forms.ModelForm):
class Meta:
model = EventRef
class LogForm(forms.ModelForm):
error_css_class = 'error'
class Meta:
model = Log
fields = ["reason"]
reason = forms.CharField(label="Reason for change",
widget=forms.widgets.Textarea(attrs={'rows':'2',
'cols': '65'}))
class PickForm(forms.Form):
picklist = forms.ChoiceField()
def __init__(self, label, item, order_by, *args, **kwargs):
super(PickForm, self).__init__(*args, **kwargs)
self.fields['picklist'].choices = \
[("", "---------")] + [(p.handle, p) for p in item.objects.all() \
.order_by(*order_by)]

File diff suppressed because it is too large Load Diff

View File

@ -1,43 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from django.db import models
from django.db.models.signals import post_save
from django.contrib.auth.models import User
def save_profile(sender, instance, created, **kwargs):
"""
Creates the profile when the user gets created.
"""
if created:
profile = Profile(user=instance)
profile.save()
class Profile(models.Model):
"""
Used to save additional information of a user, such as
themes, bookmarks, etc.
"""
user = models.OneToOneField(User, related_name="profile")
theme_type = models.ForeignKey("ThemeType", default=1) # The default is a pk?
def __str__(self):
return str(self.user)
post_save.connect(save_profile, sender=User)

View File

@ -1,3 +0,0 @@
CREATE INDEX grampsdb_childref_object_id_object_type_id
ON grampsdb_childref (object_id, object_type_id);

View File

@ -1,3 +0,0 @@
CREATE INDEX grampsdb_eventref_object_id_object_type_id
ON grampsdb_eventref (object_id, object_type_id);

View File

@ -1 +0,0 @@

View File

@ -1,3 +0,0 @@
CREATE INDEX grampsdb_noteref_object_id_object_type_id
ON grampsdb_noteref (object_id, object_type_id);

View File

@ -1,3 +0,0 @@
CREATE INDEX grampsdb_sourceref_object_id_object_type_id
ON grampsdb_sourceref (object_id, object_type_id);

View File

@ -1,230 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# webapp/grampsdb/templatetags/my_tags.py
import re
from django import template
from django.template import Library
from django.utils.safestring import mark_safe
from gramps.webapp.utils import *
from gramps.webapp.grampsdb.views import VIEWS
import gramps.webapp.utils
#escape = lambda text: text
register = Library()
def eval_template_exp(item, context):
"""
Wrapper to allow negation of variables in templates. Use
"!variable".
"""
if item.var.startswith("!"):
return not template.Variable(item.var[1:]).resolve(context)
else:
return item.resolve(context)
class TemplateNode(template.Node):
def __init__(self, args, var_name, func):
self.args = list(map(template.Variable, args))
self.var_name = var_name
self.func = func
def render(self, context):
value = self.func(*[eval_template_exp(item, context)
for item in self.args])
if self.var_name:
context[self.var_name] = value
return ''
else:
return value
def parse_tokens(tokens):
items = tokens.split_contents()
# {% tag_name arg1 arg2 arg3 as variable %}
# {% tag_name arg1 arg2 arg3 %}
tag_name = items[0]
if "as" == items[-2]:
var_name = items[-1]
args = items[1:-2]
else:
var_name = None
args = items[1:]
return (tag_name, args, var_name)
def make_tag(func):
def do_func(parser, tokens):
tag_name, args, var_name = parse_tokens(tokens)
return TemplateNode(args, var_name, func)
return do_func
for filter_name in util_filters:
func = getattr(gramps.webapp.utils, filter_name)
func.is_safe = True
register.filter(filter_name, func)
for tag_name in util_tags:
func = getattr(gramps.webapp.utils, tag_name)
register.tag(tag_name, make_tag(func))
probably_alive.is_safe = True
register.filter('probably_alive', probably_alive)
format_number.is_safe = True
register.filter('format_number', format_number)
table_count.is_safe = True
register.filter('table_count', table_count)
person_get_birth_date.is_safe = True
register.filter('person_get_birth_date', person_get_birth_date)
person_get_death_date.is_safe = True
register.filter('person_get_death_date', person_get_death_date)
display_date.is_safe = True
register.filter('display_date', display_date)
person_get_event.is_safe = True
register.filter('person_get_events', person_get_event)
def preview(text, width=40):
text = text.replace("\n", " ")
#return escape(text[:width])
if len(text) > width:
return text[:width] + "..."
return text
#preview.is_safe = True
register.filter('preview', preview)
make_name.is_safe = True
register.filter('make_name', make_name)
def preferred(person):
try:
name = person.name_set.get(preferred=True)
except:
name = None
return name
preferred.is_safe = True
register.filter('preferred', preferred)
def missing(data):
if data.strip() == "":
return "[Missing]"
#return escape(data)
return data
#missing.is_safe = True
register.filter('missing', missing)
def getViewName(item):
for view in VIEWS:
if view[1] == item:
return view[0]
if item == "name":
return "Names"
return "Unknown View"
def breadcrumb(path, arg=None):
if arg:
path = path.replace("{0}", arg)
retval = ""
for item in path.split("||"):
p, name = item.split("|", 1)
if retval != "":
retval += " > "
retval += '<a href="%s"><b>%s</b></a>' % (p.strip(), name.strip())
return "<p>%s</p>" % retval
breadcrumb.is_safe = True
register.filter('breadcrumb', breadcrumb)
def format(string, arg0=None, arg1=None, arg2=None, arg3=None, arg4=None, arg5=None, arg6=None):
try:
if arg0 is None:
return string
elif arg1 is None:
return string % arg0
elif arg2 is None:
return string % (arg0, arg1)
elif arg3 is None:
return string % (arg0, arg1, arg2)
elif arg4 is None:
return string % (arg0, arg1, arg2, arg3)
elif arg5 is None:
return string % (arg0, arg1, arg2, arg3, arg4)
elif arg6 is None:
return string % (arg0, arg1, arg2, arg3, arg4, arg5)
else:
return string % (arg0, arg1, arg2, arg3, arg4, arg5, arg6)
except:
return string
format.is_safe = True
register.simple_tag(format)
def make_args(search, page):
return gramps.webapp.utils.build_args(search=search, page=page)
make_args.is_safe = True
register.simple_tag(make_args)
def format_color(color):
return color[0:3] + color[5:7] + color[9:11]
format_color.is_safe = True
register.filter("format_color", format_color)
def currentSection(view1, view2): # tview, menu
if view1.strip().lower() in [view[1] for view in VIEWS] and view2 == "browse":
return "class=CurrentSection"
elif view1.strip().lower() == view2.strip().lower():
return "class=CurrentSection"
return ""
currentSection.is_safe = True
register.filter('currentSection', currentSection)
def row_count(row, page):
return row + (page.number - 1) * page.paginator.per_page
register.filter('row_count', row_count)
def table_header(context, headers = None):
# add things for the header here
if headers:
context["headers"] = headers
return context
register.inclusion_tag('table_header.html',
takes_context=True)(table_header)
def paginator(context, adjacent_pages=2):
"""
To be used in conjunction with the object_list generic view.
Adds pagination context variables for use in displaying first, adjacent and
last page links in addition to those created by the object_list generic
view.
"""
results_this_page = context["page"].object_list.count()
context.update({'results_this_page': results_this_page,})
return context
register.inclusion_tag('paginator.html',
takes_context=True)(paginator)

View File

@ -1,29 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from .person import *
from .family import *
from .event import *
from .note import *
from .media import *
from .citation import *
from .source import *
from .place import *
from .repository import *
from .tag import *

View File

@ -1,141 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, build_search
from gramps.webapp.grampsdb.models import Citation
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface
## Django Modules
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_citation(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Citation")
context["tviews"] = _("Citations")
context["action"] = "view"
view_template = "view_citation_detail.html"
if handle == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
# Handle: edit, view, add, create, save, delete, share, save-share
if act == "share":
item, handle = add_to
context["pickform"] = PickForm("Pick citation",
Citation,
(),
request.POST)
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "save-share":
item, handle = add_to
pickform = PickForm("Pick citation",
Citation,
(),
request.POST)
if pickform.data["picklist"]:
parent_model = dji.get_model(item) # what model?
parent_obj = parent_model.objects.get(handle=handle) # to add
ref_handle = pickform.data["picklist"]
ref_obj = Citation.objects.get(handle=ref_handle)
dji.add_citation_ref_default(parent_obj, ref_obj)
parent_obj.save_cache() # rebuild cache
return redirect("/%s/%s%s#tab-citations" % (item, handle, build_search(request)))
else:
context["pickform"] = pickform
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "add":
source = Source(gramps_id=dji.get_next_id(Source, "S"))
sourceform = SourceForm(instance=source)
sourceform.model = source
citation = Citation(source=source, gramps_id=dji.get_next_id(Citation, "C"))
citationform = CitationForm(instance=citation)
citationform.model = citation
elif act in ["view", "edit"]:
citation = Citation.objects.get(handle=handle)
citationform = CitationForm(instance=citation)
citationform.model = citation
source = citation.source
sourceform = SourceForm(instance=source)
sourceform.model = source
elif act == "save":
citation = Citation.objects.get(handle=handle)
citationform = CitationForm(request.POST, instance=citation)
citationform.model = citation
if citationform.is_valid():
update_last_changed(citation, request.user.username)
citation = citationform.save()
act = "view"
else:
act = "edit"
elif act == "create":
source = Source(handle=create_id())
sourceform = SourceForm(request.POST, instance=source)
sourceform.model = source
citation = Citation(handle=create_id(), source=source)
citationform = CitationForm(request.POST, instance=citation)
citationform.model = citation
if citationform.is_valid() and sourceform.is_valid():
update_last_changed(source, request.user.username)
source = sourceform.save()
citation.source = source
update_last_changed(citation, request.user.username)
citation = citationform.save(save_cache=False)
source.save_cache()
citation.save_cache()
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_citation_ref(obj, citation.handle)
obj.save_cache()
return redirect("/%s/%s#tab-citations" % (item, handle))
act = "view"
else:
act = "add"
elif act == "delete":
citation = Citation.objects.get(handle=handle)
citation.delete()
return redirect("/citation/")
else:
raise Exception("Unhandled act: '%s'" % act)
context["citationform"] = citationform
context["sourceform"] = sourceform
context["object"] = citation
context["citation"] = citation
context["source"] = source
context["action"] = act
return render_to_response(view_template, context)

View File

@ -1,227 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, build_search, db
from gramps.webapp.grampsdb.models import Event, EventType, EventRef, EventRoleType, Person
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface, lookup_role_index
from gramps.webapp.djangodb import DbDjango
from gramps.gen.datehandler import displayer, parser
## Django Modules
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
dd = displayer.display
dp = parser.parse
def delete_event(event):
obj_type = ContentType.objects.get_for_model(Person)
# First, get those items we need to update:
event_refs = EventRef.objects.filter(
ref_object=event,
object_type=obj_type,
role_type=get_type_from_name(EventRoleType, "Primary")
)
people = []
for event_ref in event_refs:
try:
person = Person.objects.get(id=event_ref.object_id)
except:
print("Warning: Corrupt reference in delete_event: %s" % event_ref)
continue
people.append(person)
# Remove links to birth/death:
for person in people:
if person.death == event:
person.death = None
person.save()
elif person.birth == event:
person.birth = None
person.save()
# Now, delete the event:
event.delete()
# Now, update all of the people:
for person in people:
recheck_birth_death_refs(person)
person.save()
def check_event(event):
obj_type = ContentType.objects.get_for_model(Person)
# First, get those items we need to update:
event_refs = EventRef.objects.filter(
ref_object=event,
object_type=obj_type,
role_type=get_type_from_name(EventRoleType, "Primary")
)
people = []
for event_ref in event_refs:
try:
person = Person.objects.get(id=event_ref.object_id)
except:
print("Warning: Corrupt reference in delete_event: %s" % event_ref)
continue
recheck_birth_death_refs(person)
person.save()
def recheck_birth_death_refs(person):
"""
Reset birth/death references. Need to save later.
"""
all_events = dji.get_event_ref_list(person)
obj_type = ContentType.objects.get_for_model(person)
# Update Birth event references:
events = EventRef.objects.filter(
object_id=person.id,
object_type=obj_type,
role_type=get_type_from_name(EventRoleType, "Primary"),
ref_object__event_type__val=EventType.BIRTH).order_by("order")
if events:
person.birth = events[0].ref_object
new_index = lookup_role_index(EventType.BIRTH, all_events)
if person.birth_ref_index != new_index:
person.birth_ref_index = new_index
else:
person.birth = None
person.birth_ref_index = -1
# Update Death event references:
events = EventRef.objects.filter(
object_id=person.id,
object_type=obj_type,
role_type=get_type_from_name(EventRoleType, "Primary"),
ref_object__event_type__val=EventType.DEATH).order_by("order")
if events:
person.death = events[0].ref_object
new_index = lookup_role_index(EventType.DEATH, all_events)
if person.death_ref_index != new_index:
person.death_ref_index = new_index
else:
person.death = None
person.death_ref_index = -1
def process_event(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Event")
context["tviews"] = _("Events")
context["action"] = "view"
view_template = "view_event_detail.html"
if handle == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
# Handle: edit, view, add, create, save, delete, share, save-share
if act == "share":
item, handle = add_to
context["pickform"] = PickForm("Pick event",
Event,
(),
request.POST)
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "save-share":
item, handle = add_to
pickform = PickForm("Pick event",
Event,
(),
request.POST)
if pickform.data["picklist"]:
parent_model = dji.get_model(item) # what model?
parent_obj = parent_model.objects.get(handle=handle) # to add
ref_handle = pickform.data["picklist"]
ref_obj = Event.objects.get(handle=ref_handle)
dji.add_event_ref_default(parent_obj, ref_obj)
if item == "person": # then need to recheck birth/death indexes:
recheck_birth_death_refs(parent_obj)
parent_obj.save(save_cache=False)
parent_obj.save_cache()
return redirect("/%s/%s%s#tab-events" % (item, handle, build_search(request)))
else:
context["pickform"] = pickform
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "add":
event = Event(gramps_id=dji.get_next_id(Event, "E"))
eventform = EventForm(instance=event)
eventform.model = event
elif act in ["view", "edit"]:
event = Event.objects.get(handle=handle)
genlibevent = db.get_event_from_handle(handle)
if genlibevent:
date = genlibevent.get_date_object()
event.text = dd(date)
eventform = EventForm(instance=event)
eventform.model = event
elif act == "save":
event = Event.objects.get(handle=handle)
eventform = EventForm(request.POST, instance=event)
eventform.model = event
if eventform.is_valid():
update_last_changed(event, request.user.username)
event = eventform.save()
# Check any person that might be referenced to see if
# birth/death issues changed:
check_event(event)
event.save()
act = "view"
else:
act = "edit"
elif act == "create":
event = Event(handle=create_id())
eventform = EventForm(request.POST, instance=event)
eventform.model = event
if eventform.is_valid():
update_last_changed(event, request.user.username)
event = eventform.save()
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_event_ref_default(obj, event)
if item == "person": # then need to recheck birth/death indexes:
recheck_birth_death_refs(obj)
obj.save(save_cache=False)
obj.save_cache()
return redirect("/%s/%s#tab-events" % (item, handle))
act = "view"
else:
act = "add"
elif act == "delete":
event = Event.objects.get(handle=handle)
delete_event(event)
return redirect("/event/")
else:
raise Exception("Unhandled act: '%s'" % act)
context["eventform"] = eventform
context["object"] = event
context["event"] = event
context["action"] = act
return render_to_response(view_template, context)

View File

@ -1,201 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, build_search
from gramps.webapp.grampsdb.models import Family
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface
from gramps.gen.utils.id import create_id
## Django Modules
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_family(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Family")
context["tviews"] = _("Familes")
if handle == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
# Handle: edit, view, add, create, save, delete, share, save-share
if act == "share":
# Adds a person to an existing family
item, handle = add_to
context["pickform"] = PickForm("Pick family",
Family,
(),
request.POST)
context["object_handle"] = handle
context["object_type"] = "person"
return render_to_response("pick.html", context)
elif act == "save-share":
item, handle = add_to
pickform = PickForm("Pick family",
Family,
(),
request.POST)
if pickform.data["picklist"]:
person = Person.objects.get(handle=handle) # to add
ref_handle = pickform.data["picklist"]
ref_obj = Family.objects.get(handle=ref_handle)
if item == "child":
dji.add_child_ref_default(ref_obj, person) # add person to family
#person.parent_families.add(ref_obj) # add family to child
pfo = MyParentFamilies(person=person, family=ref_obj,
order=len(person.parent_families.all())+1)
pfo.save()
elif item == "spouse":
if person.gender_type.name == "Female":
ref_obj.mother = person
elif person.gender_type.name == "Male":
ref_obj.father = person
else:
ref_obj.father = person # FIXME: Unknown gender, add to open
#person.families.add(ref_obj) # add family to person
pfo = MyFamilies(person=person, family=ref_obj,
order=len(person.families.all())+1)
pfo.save()
ref_obj.save()
person.save()
return redirect("/%s/%s%s#tab-references" % ("person", handle, build_search(request)))
else:
context["pickform"] = pickform
context["object_handle"] = handle
context["object_type"] = "person"
return render_to_response("pick.html", context)
elif act == "add":
family = Family(
gramps_id=dji.get_next_id(Family, "F"),
family_rel_type=FamilyRelType.objects.get(
val=FamilyRelType._DEFAULT[0]))
if add_to:
what, phandle = add_to
person = Person.objects.get(handle=phandle)
gender = person.gender_type.name # Male, Female, Unknown
if what == "spouse":
if gender == "Male":
family.father = person
elif gender == "Female":
family.mother = person
else: # You have to pick one!
family.father = person
elif what == "child":
pass # FIXME: can't show child in table?
# Table from children_table
else: # unknown what!
raise Exception("can't add_to: '%s'" % what)
familyform = FamilyForm(instance=family)
familyform.model = family
elif act in ["view", "edit"]:
family = Family.objects.get(handle=handle)
familyform = FamilyForm(instance=family)
familyform.model = family
elif act == "save": # editing an existing family
family = Family.objects.get(handle=handle)
old_family_mother = family.mother
old_family_father = family.father
familyform = FamilyForm(request.POST, instance=family)
familyform.model = family
if familyform.is_valid():
update_last_changed(family, request.user.username)
family = familyform.save()
# Remove family from previous mother/father if changed
if familyform.cleaned_data["mother"] != old_family_mother and old_family_mother:
MyFamilies.objects.get(person=old_family_mother, family=family).delete()
if familyform.cleaned_data["father"] != old_family_father and old_family_father:
MyFamilies.objects.get(person=old_family_father, family=family).delete()
# Add family to newly selected mother/father if needed:
if familyform.cleaned_data["mother"]:
if family not in familyform.cleaned_data["mother"].families.all():
#family.mother.families.add(family)
pfo = MyFamilies(person=familyform.cleaned_data["mother"], family=family,
order=len(familyform.cleaned_data["mother"].families.all())+1)
pfo.save()
if familyform.cleaned_data["father"]:
if family not in familyform.cleaned_data["father"].families.all():
#family.father.families.add(family)
pfo = MyFamilies(person=family.father, family=family,
order=len(familyform.cleaned_data["father"].families.all())+1)
pfo.save()
familyform.save()
act = "view"
else:
act = "edit"
elif act == "create":
family = Family(family_rel_type=FamilyRelType.objects.get(
val=FamilyRelType._DEFAULT[0]),
handle=create_id())
familyform = FamilyForm(request.POST, instance=family)
familyform.model = family
if familyform.is_valid():
update_last_changed(family, request.user.username)
family = familyform.save()
if family.mother:
#family.mother.families.add(family)
pfo = MyFamilies(person=family.mother, family=family,
order=len(family.mother.families.all())+1)
pfo.save()
if family.father:
#family.father.families.add(family)
pfo = MyFamilies(person=family.father, family=family,
order=len(family.father.families.all())+1)
pfo.save()
family.save_cache()
if add_to: # add child or spouse to family
item, handle = add_to
person = Person.objects.get(handle=handle)
if item == "child":
dji.add_child_ref_default(family, person) # add person to family
##person.parent_families.add(family) # add family to child
pfo = MyParentFamilies(person=person, family=family,
order=len(person.parent_families.all())+1)
pfo.save()
#elif item == "spouse":
# already added by selecting
person.save()
return redirect("/%s/%s%s#tab-references" % ("person", handle, build_search(request)))
act = "view"
else:
act = "add"
elif act == "delete":
family = Family.objects.get(handle=handle)
family.delete()
return redirect("/family/")
else:
raise Exception("Unhandled act: '%s'" % act)
context["familyform"] = familyform
context["object"] = family
context["family"] = family
context["action"] = act
view_template = "view_family_detail.html"
return render_to_response(view_template, context)

View File

@ -1,203 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, build_search
from gramps.webapp.grampsdb.models import Media
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface
from gramps.gen.config import config
## Django Modules
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
from django.http import HttpResponse
## Other Python Modules
try:
from PIL import Image
NEW_PIL = [int(i) for i in Image.VERSION.split(".")] >= [1, 1, 7]
if not NEW_PIL:
from . import png
except:
print("WARNING: No PIL installed or available")
NEW_PIL = False
from . import png
import os
## Globals
dji = DjangoInterface()
def pb2image(pb):
width, height = pb.get_width(), pb.get_height()
return Image.fromstring("RGB", (width,height), pb.get_pixels())
def process_media(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Media")
context["tviews"] = _("Media")
context["action"] = "view"
view_template = "view_media_detail.html"
if handle == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
# Handle: edit, view, add, create, save, delete, share, save-share
if act == "share":
item, handle = add_to
context["pickform"] = PickForm("Pick media",
Media,
(),
request.POST)
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "save-share":
item, handle = add_to
pickform = PickForm("Pick media",
Media,
(),
request.POST)
if pickform.data["picklist"]:
parent_model = dji.get_model(item) # what model?
parent_obj = parent_model.objects.get(handle=handle) # to add
ref_handle = pickform.data["picklist"]
ref_obj = Media.objects.get(handle=ref_handle)
dji.add_media_ref_default(parent_obj, ref_obj)
parent_obj.save_cache() # rebuild cache
return redirect("/%s/%s%s#tab-media" % (item, handle, build_search(request)))
else:
context["pickform"] = pickform
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "full":
media = Media.objects.get(handle=handle)
media_type, media_ext = media.mime.split("/", 1)
# FIXME: This should be absolute:
folder = Config.objects.get(setting="behavior.addmedia-image-dir").value
# FIXME: media.path should not have any .. for security
response = HttpResponse(content_type=media.mime)
if NEW_PIL or media_ext != "png":
image = Image.open("%s/%s" % (folder, media.path))
image.save(response, media_ext)
else:
# FIXME: older PIL 1.1.6 cannot read interlaced PNG files
reader = png.Reader(filename="%s/%s" % (folder, media.path))
x, y, pixels, meta = reader.asDirect()
image = png.Image(pixels, meta)
image.save(response)
return response
elif act == "thumbnail":
media = Media.objects.get(handle=handle)
media_type, media_ext = media.mime.split("/", 1)
# FIXME: This should be absolute:
folder = Config.objects.get(setting="behavior.addmedia-image-dir").value
# FIXME: media.path should not have any .. for security
response = HttpResponse(content_type=media.mime)
if os.path.exists("%s/thumbnail/%s" % (folder, media.path)):
if NEW_PIL or media_ext != "png":
image = Image.open("%s/thumbnail/%s" % (folder, media.path))
image.save(response, media_ext)
else:
# FIXME: older PIL 1.1.6 cannot read interlaced PNG files
reader = png.Reader(filename="%s/thumbnail/%s" % (folder, media.path))
x, y, pixels, meta = reader.asDirect()
image = png.Image(pixels, meta)
image.save(response)
else:
try:
os.makedirs("%s/thumbnail" % folder)
except:
pass
if NEW_PIL or media_ext != "png":
image = Image.open("%s/%s" % (folder, media.path))
image.thumbnail((300,300), Image.ANTIALIAS)
image.save("%s/thumbnail/%s" % (folder, media.path), media_ext)
image.save(response, media_ext)
else:
# FIXME: older PIL 1.1.6 cannot read interlaced PNG files
reader = png.Reader(filename="%s/%s" % (folder, media.path))
x, y, pixels, meta = reader.asDirect()
meta["interlace"] = False
image = png.Image(pixels, meta)
image.save("/tmp/%s" % media.path)
# Now open in PIL to rescale
image = Image.open("/tmp/%s" % media.path)
image.thumbnail((300,300), Image.ANTIALIAS)
image.save("%s/thumbnail/%s" % (folder, media.path), media_ext)
image.save(response, media_ext.upper())
return response
elif act == "add":
media = Media(gramps_id=dji.get_next_id(Media, "M"))
mediaform = MediaForm(instance=media)
mediaform.model = media
elif act in ["view", "edit"]:
media = Media.objects.get(handle=handle)
mediaform = MediaForm(instance=media)
mediaform.model = media
elif act == "save":
media = Media.objects.get(handle=handle)
mediaform = MediaForm(request.POST, instance=media)
mediaform.model = media
if mediaform.is_valid():
update_last_changed(media, request.user.username)
media = mediaform.save()
act = "view"
else:
act = "edit"
elif act == "create":
media = Media(handle=create_id())
mediaform = MediaForm(request.POST, instance=media)
mediaform.model = media
if mediaform.is_valid():
update_last_changed(media, request.user.username)
media = mediaform.save(save_cache=False)
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_media_ref_default(obj, media)
obj.save_cache()
media.save_cache()
return redirect("/%s/%s#tab-gallery" % (item, handle))
else:
media.save_cache()
act = "view"
else:
act = "add"
elif act == "delete":
media = Media.objects.get(handle=handle)
media.delete()
return redirect("/media/")
else:
raise Exception("Unhandled act: '%s'" % act)
context["mediaform"] = mediaform
context["object"] = media
context["media"] = media
context["action"] = act
return render_to_response(view_template, context)

View File

@ -1,153 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, StyledNoteFormatter, parse_styled_text, build_search, db
from gramps.webapp.grampsdb.models import Note
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface
from gramps.webapp.djangodb import DbDjango
## Django Modules
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
snf = StyledNoteFormatter(db)
# add a note to a person:
# /note/add/person/c51759195496de06da3ca5ba2c1
def process_note_on_name(request, action, handle, order):
# add, edit, delete
raise Exception("testing")
def process_note(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Note")
context["tviews"] = _("Notes")
context["action"] = "view"
view_template = "view_note_detail.html"
if handle == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
# Handle: edit, view, add, create, save, delete, share, save-share
if act == "share":
item, handle = add_to
context["pickform"] = PickForm("Pick note",
Note,
(),
request.POST)
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "save-share":
item, handle = add_to
pickform = PickForm("Pick note",
Note,
(),
request.POST)
if pickform.data["picklist"]:
parent_model = dji.get_model(item) # what model?
parent_obj = parent_model.objects.get(handle=handle) # to add
ref_handle = pickform.data["picklist"]
ref_obj = Note.objects.get(handle=ref_handle)
dji.add_note_ref(parent_obj, ref_obj)
parent_obj.save_cache() # rebuild cache
return redirect("/%s/%s%s#tab-notes" % (item, handle, build_search(request)))
else:
context["pickform"] = pickform
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "add":
note = Note(gramps_id=dji.get_next_id(Note, "N"))
notetext = ""
noteform = NoteForm(instance=note, initial={"notetext": notetext})
noteform.model = note
elif act in ["view", "edit"]:
note = Note.objects.get(handle=handle)
genlibnote = db.get_note_from_handle(note.handle)
notetext = snf.format(genlibnote)
noteform = NoteForm(instance=note, initial={"notetext": notetext})
noteform.model = note
elif act == "save":
note = Note.objects.get(handle=handle)
notetext = ""
noteform = NoteForm(request.POST, instance=note, initial={"notetext": notetext})
noteform.model = note
if noteform.is_valid():
update_last_changed(note, request.user.username)
notedata = parse_styled_text(noteform.data["notetext"])
note.text = notedata[0]
note = noteform.save()
dji.save_note_markup(note, notedata[1])
note.save_cache()
notetext = noteform.data["notetext"]
act = "view"
else:
notetext = noteform.data["notetext"]
act = "edit"
elif act == "create":
note = Note(handle=create_id())
notetext = ""
noteform = NoteForm(request.POST, instance=note, initial={"notetext": notetext})
noteform.model = note
if noteform.is_valid():
update_last_changed(note, request.user.username)
notedata = parse_styled_text(noteform.data["notetext"])
note.text = notedata[0]
note = noteform.save()
dji.save_note_markup(note, notedata[1])
note.save_cache()
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_note_ref(obj, note)
obj.save_cache()
return redirect("/%s/%s#tab-notes" % (item, handle))
notetext = noteform.data["notetext"]
act = "view"
else:
notetext = noteform.data["notetext"]
act = "add"
elif act == "delete":
# FIXME: delete markup too for this note
note = Note.objects.get(handle=handle)
note.delete()
return redirect("/note/")
else:
raise Exception("Unhandled act: '%s'" % act)
context["noteform"] = noteform
context["object"] = note
context["notetext"] = notetext
context["note"] = note
context["action"] = act
return render_to_response(view_template, context)

View File

@ -1,529 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, build_search, make_log
from gramps.webapp.grampsdb.models import Person, Name, Surname
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface
## Django Modules
from django.http import Http404
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
## Functions
def check_order(request, person):
"""
Check for proper ordering 1..., and for a preferred name.
"""
order = 1
preferred = False
for name in person.name_set.all().order_by("order"):
if name.preferred:
preferred = True
if name.order != order:
name.order = order
update_last_changed(name, request.user.username)
name.save()
order += 1
if not preferred:
name = person.name_set.get(order=1)
name.preferred = True
update_last_changed(name, request.user.username)
name.save()
def check_primary(surname, surnames):
"""
Check for a proper primary surname.
"""
if surname.primary:
# then all rest should not be:
for s in surnames:
if s.primary:
s.primary = False
s.save()
else:
# then one of them should be
ok = False
for s in surnames:
if s.id != surname.id:
if s.primary:
ok = True
break
else:
s.primary = False
s.save()
ok = True
break
if not ok:
surname.primary = True
def check_preferred(request, name, person):
"""
Check for a proper preferred name.
"""
names = []
if person:
names = person.name_set.all()
if name.preferred:
# then all reast should not be:
for s in names:
if s.preferred and s.id != name.id:
s.preferred = False
update_last_changed(s, request.user.username)
s.save()
else:
# then one of them should be
ok = False
for s in names:
if s.id != name.id:
if s.preferred:
ok = True
break
else:
s.preferred = False
update_last_changed(s, request.user.username)
s.save()
ok = True
break
if not ok:
name.preferred = True
def process_surname(request, handle, order, sorder, act="view"):
#import pdb; pdb.set_trace()
# /sdjhgsdjhdhgsd/name/1/surname/1 (view)
# /sdjhgsdjhdhgsd/name/1/surname/add
# /sdjhgsdjhdhgsd/name/1/surname/2/[edit|view|add|delete]
if sorder == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
person = Person.objects.get(handle=handle)
name = person.name_set.get(order=order)
if act in ["view", "edit"]:
surname = name.surname_set.get(order=sorder)
if act == "edit":
surname.prefix = make_empty(True, surname.prefix, " prefix ")
elif act in ["delete"]:
surnames = name.surname_set.all().order_by("order")
if len(surnames) > 1:
neworder = 1
for surname in surnames:
if surname.order != neworder:
surname.order = neworder
surname.save()
neworder += 1
elif surname.order == int(sorder):
surname.delete()
else:
neworder += 1
else:
request.user.message_set.create(message="You can't delete the only surname")
return redirect("/person/%s/name/%s%s#tab-surnames" % (person.handle, name.order,
build_search(request)))
elif act in ["add"]:
surname = Surname(name=name, primary=False,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
surname.prefix = make_empty(True, surname.prefix, " prefix ")
elif act == "create":
surnames = name.surname_set.all().order_by("order")
sorder = 1
for surname in surnames:
sorder += 1
surname = Surname(name=name, primary=True,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]),
order=sorder)
sf = SurnameForm(request.POST, instance=surname)
sf.model = surname
if sf.is_valid():
surname.prefix = ssf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname = sf.save(commit=False)
check_primary(surname, surnames)
surname.save()
person.save_cache()
return redirect("/person/%s/name/%s/surname/%s%s#tab-surnames" %
(person.handle, name.order, sorder,
build_search(request)))
act = "add"
surname.prefix = make_empty(True, surname.prefix, " prefix ")
elif act == "save":
surname = name.surname_set.get(order=sorder)
sf = SurnameForm(request.POST, instance=surname)
sf.model = surname
if sf.is_valid():
surname.prefix = ssf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname = sf.save(commit=False)
check_primary(surname, name.surname_set.all().exclude(order=surname.order))
surname.save()
person.save_cache()
return redirect("/person/%s/name/%s/surname/%s%s#tab-surnames" %
(person.handle, name.order, sorder,
build_search(request)))
act = "edit"
surname.prefix = make_empty(True, surname.prefix, " prefix ")
# else, edit again
else:
raise Exception("unknown act: '%s'" % act)
sf = SurnameForm(instance=surname)
sf.model = surname
context = RequestContext(request)
context["action"] = act
context["tview"] = _("Surname")
context["handle"] = handle
context["id"] = id
context["person"] = person
context["object"] = person
context["surnameform"] = sf
context["order"] = name.order
context["sorder"] = sorder
view_template = 'view_surname_detail.html'
return render_to_response(view_template, context)
def process_name(request, handle, order, act="view"):
if order == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
### Process act:
if act in "view":
pf, nf, sf, person = get_person_forms(handle, order=order)
name = nf.model
elif act == "edit":
pf, nf, sf, person = get_person_forms(handle, order=order)
name = nf.model
elif act == "delete":
person = Person.objects.get(handle=handle)
name = person.name_set.filter(order=order)
names = person.name_set.all()
if len(names) > 1:
name.delete()
check_order(request, person)
else:
request.user.message_set.create(message = "Can't delete only name.")
return redirect("/person/%s%s#tab-names" % (person.handle,
build_search(request)))
elif act == "add": # add name
person = Person.objects.get(handle=handle)
name = Name(person=person,
preferred=False,
display_as=NameFormatType.objects.get(val=NameFormatType._DEFAULT[0]),
sort_as=NameFormatType.objects.get(val=NameFormatType._DEFAULT[0]),
name_type=NameType.objects.get(val=NameType._DEFAULT[0]))
nf = NameForm(instance=name)
nf.model = name
surname = Surname(name=name,
primary=True,
order=1,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
sf = SurnameForm(request.POST, instance=surname)
sf.model = surname
elif act == "create":
# make new data
person = Person.objects.get(handle=handle)
name = Name(preferred=False)
next_order = max([name.order for name in person.name_set.all()]) + 1
surname = Surname(name=name,
primary=True,
order=next_order,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
# combine with user data:
nf = NameForm(request.POST, instance=name)
name.id = None # FIXME: why did this get set to an existing name? Should be new. Remove from form?
name.preferred = False
nf.model = name
sf = SurnameForm(request.POST, instance=surname)
sf.model = surname
if nf.is_valid() and sf.is_valid():
# name.preferred and surname.primary get set False in the above is_valid()
# person = pf.save()
# Process data:
name = nf.save(commit=False)
name.person = person
update_last_changed(name, request.user.username)
# Manually set any data:
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else ""
name.preferred = False # FIXME: why is this False? Remove from form?
name.order = next_order
name.save()
# Process data:
surname = sf.save(commit=False)
surname.name = name
# Manually set any data:
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False? Remove from form?
surname.save()
person.save_cache()
return redirect("/person/%s/name/%s%s#tab-surnames" % (person.handle, name.order,
build_search(request)))
else:
act = "add"
elif act == "save":
# look up old data:
person = Person.objects.get(handle=handle)
oldname = person.name_set.get(order=order)
oldsurname = oldname.surname_set.get(primary=True)
# combine with user data:
pf = PersonForm(request.POST, instance=person)
pf.model = person
nf = NameForm(request.POST, instance=oldname)
nf.model = oldname
sf = SurnameForm(request.POST, instance=oldsurname)
sf.model = oldsurname
if nf.is_valid() and sf.is_valid():
# name.preferred and surname.primary get set False in the above is_valid()
# person = pf.save()
# Process data:
oldname.person = person
name = nf.save()
# Manually set any data:
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else ""
name.preferred = True # FIXME: why is this False? Remove from form?
update_last_changed(name, request.user.username)
check_preferred(request, name, person)
name.save()
# Process data:
oldsurname.name = name
surname = sf.save(commit=False)
# Manually set any data:
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False? Remove from form?
surname.save()
person.save_cache()
return redirect("/person/%s/name/%s%s#tab-surnames" % (person.handle, name.order,
build_search(request)))
else:
act = "edit"
context = RequestContext(request)
context["action"] = act
context["tview"] = _('Name')
context["tviews"] = _('Names')
context["view"] = 'name'
context["handle"] = handle
context["id"] = id
context["person"] = person
context["object"] = person
context["nameform"] = nf
context["surnameform"] = sf
context["order"] = order
context["next"] = "/person/%s/name/%d" % (person.handle, name.order)
view_template = "view_name_detail.html"
return render_to_response(view_template, context)
def process_person(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Person")
context["tviews"] = _("People")
logform = None
if request.user.is_authenticated():
if act == "share":
item, handle = add_to
context["pickform"] = PickForm("Pick a person",
Person,
("name__surname__surname",
"name__first_name"),
request.POST)
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "save-share":
item, handle = add_to # ("Family", handle)
pickform = PickForm("Pick a person",
Person,
("name__surname__surname",
"name__first_name"),
request.POST)
if pickform.data["picklist"]:
person_handle = pickform.data["picklist"]
person = Person.objects.get(handle=person_handle)
model = dji.get_model(item) # what model?
obj = model.objects.get(handle=handle) # get family
dji.add_child_ref_default(obj, person) # add person to family
#person.parent_families.add(obj) # add family to child
pfo = MyParentFamilies(person=person, family=obj,
order=len(person.parent_families.all())+1)
pfo.save()
person.save_cache() # rebuild child
obj.save_cache() # rebuild family
return redirect("/%s/%s%s" % (item, handle, build_search(request)))
else:
context["pickform"] = pickform
context["object_handle"] = handle
context["object_type"] = "family"
return render_to_response("pick.html", context)
elif act in ["edit", "view"]:
pf, nf, sf, person = get_person_forms(handle, empty=False)
if act == "edit":
logform = LogForm()
elif act == "add":
pf, nf, sf, person = get_person_forms(handle=None, protect=False, empty=True)
logform = LogForm()
elif act == "delete":
pf, nf, sf, person = get_person_forms(handle, protect=False, empty=True)
person.delete()
return redirect("/person/%s" % build_search(request))
elif act in ["save", "create"]: # could be create a new person
# look up old data, if any:
logform = LogForm(request.POST)
if handle:
person = Person.objects.get(handle=handle)
name = person.name_set.get(preferred=True)
surname = name.surname_set.get(primary=True)
else: # create new item
person = Person(handle=create_id())
name = Name(person=person, preferred=True)
surname = Surname(name=name, primary=True, order=1)
surname = Surname(name=name,
primary=True,
order=1,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]))
# combine with user data:
pf = PersonForm(request.POST, instance=person)
pf.model = person
nf = NameFormFromPerson(request.POST, instance=name)
nf.model = name
sf = SurnameForm(request.POST, instance=surname)
sf.model = surname
# check if valid:
if nf.is_valid() and pf.is_valid() and sf.is_valid() and logform.is_valid():
# name.preferred and surname.primary get set False in the above is_valid()
update_last_changed(person, request.user.username)
person = pf.save(save_cache=False)
# Process data:
name.person = person
name = nf.save(commit=False)
# Manually set any data:
name.suffix = nf.cleaned_data["suffix"] if nf.cleaned_data["suffix"] != " suffix " else ""
name.preferred = True # FIXME: why is this False? Remove from form?
check_preferred(request, name, person)
update_last_changed(name, request.user.username)
name.save()
# Process data:
surname.name = name
surname = sf.save(commit=False)
# Manually set any data:
surname.prefix = sf.cleaned_data["prefix"] if sf.cleaned_data["prefix"] != " prefix " else ""
surname.primary = True # FIXME: why is this False? Remove from form?
surname.save()
# FIXME: put this in correct place to get correct cache, before changes:
make_log(person, act, request.user.username, logform.cleaned_data["reason"], person.cache)
if add_to: # Adding a child to the family
item, handle = add_to # ("Family", handle)
model = dji.get_model(item) # what model?
obj = model.objects.get(handle=handle) # get family
dji.add_child_ref_default(obj, person) # add person to family
#person.parent_families.add(obj) # add family to child
pfo = MyParentFamilies(person=person, family=obj,
order=len(person.parent_families.all())+1)
pfo.save()
person.save_cache() # rebuild child
obj.save_cache() # rebuild family
return redirect("/%s/%s%s" % (item, handle, build_search(request)))
person.save_cache()
return redirect("/person/%s%s" % (person.handle, build_search(request)))
else:
# need to edit again
if handle:
act = "edit"
else:
act = "add"
else: # error?
raise Http404(_("Requested %s does not exist.") % "person")
else: # not authenticated
# BEGIN NON-AUTHENTICATED ACCESS
try:
person = Person.objects.get(handle=handle)
except:
raise Http404(_("Requested %s does not exist.") % "person")
if person.private:
raise Http404(_("Requested %s does not exist.") % "person")
pf, nf, sf, person = get_person_forms(handle, protect=True)
# END NON-AUTHENTICATED ACCESS
context["action"] = act
context["view"] = "person"
context["tview"] = _("Person")
context["tviews"] = _("People")
context["personform"] = pf
context["nameform"] = nf
context["surnameform"] = sf
context["logform"] = logform
context["person"] = person
context["object"] = person
context["next"] = "/person/%s" % person.handle
def get_person_forms(handle, protect=False, empty=False, order=None):
if handle:
person = Person.objects.get(handle=handle)
else:
person = Person(gramps_id=dji.get_next_id(Person, "I"))
## get a name
name = None
if order is not None:
try:
name = person.name_set.get(order=order)
except:
pass
if name is None:
try:
name = person.name_set.get(preferred=True)
except:
name = Name(person=person, preferred=True,
display_as=NameFormatType.objects.get(val=NameFormatType._DEFAULT[0]),
sort_as=NameFormatType.objects.get(val=NameFormatType._DEFAULT[0]),
name_type=NameType.objects.get(val=NameType._DEFAULT[0]))
## get a surname
try:
surname = name.surname_set.get(primary=True)
except:
surname = Surname(name=name, primary=True,
name_origin_type=NameOriginType.objects.get(val=NameOriginType._DEFAULT[0]),
order=1)
if protect and person.probably_alive:
name.sanitize()
pf = PersonForm(instance=person)
pf.model = person
name.suffix = make_empty(empty, name.suffix, " suffix ")
nf = NameForm(instance=name)
nf.model = name
surname.prefix = make_empty(empty, surname.prefix, " prefix ")
sf = SurnameForm(instance=surname)
sf.model = surname
return pf, nf, sf, person
def make_empty(empty, value, empty_value):
if value:
return value
elif empty:
return empty_value
else:
return value

View File

@ -1,97 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed
from gramps.webapp.grampsdb.models import Place
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface
## Django Modules
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_place(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Place")
context["tviews"] = _("Places")
context["action"] = "view"
view_template = "view_place_detail.html"
if handle == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
# Handle: edit, view, add, create, save, delete
if act == "add":
place = Place(gramps_id=dji.get_next_id(Place, "P"))
placeform = PlaceForm(instance=place)
placeform.model = place
elif act in ["view", "edit"]:
place = Place.objects.get(handle=handle)
placeform = PlaceForm(instance=place)
placeform.model = place
elif act == "save":
place = Place.objects.get(handle=handle)
placeform = PlaceForm(request.POST, instance=place)
placeform.model = place
if placeform.is_valid():
update_last_changed(place, request.user.username)
place = placeform.save()
act = "view"
else:
act = "edit"
elif act == "create":
place = Place(handle=create_id())
placeform = PlaceForm(request.POST, instance=place)
placeform.model = place
if placeform.is_valid():
update_last_changed(place, request.user.username)
place = placeform.save()
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_place_ref(obj, place.handle)
obj.save_cache()
return redirect("/%s/%s#tab-places" % (item, handle))
act = "view"
else:
act = "add"
elif act == "delete":
place = Place.objects.get(handle=handle)
place.delete()
return redirect("/place/")
else:
raise Exception("Unhandled act: '%s'" % act)
context["placeform"] = placeform
context["object"] = place
context["place"] = place
context["action"] = act
return render_to_response(view_template, context)

File diff suppressed because it is too large Load Diff

View File

@ -1,126 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, build_search
from gramps.webapp.grampsdb.models import Repository
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface
## Django Modules
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_repository(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Repository")
context["tviews"] = _("Repositories")
context["action"] = "view"
view_template = "view_repository_detail.html"
if handle == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
# Handle: edit, view, add, create, save, delete, share, save-share
if act == "share":
item, handle = add_to
context["pickform"] = PickForm("Pick repository",
Repository,
(),
request.POST)
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "save-share":
item, handle = add_to
pickform = PickForm("Pick repository",
Repository,
(),
request.POST)
if pickform.data["picklist"]:
parent_model = dji.get_model(item) # what model?
parent_obj = parent_model.objects.get(handle=handle) # to add
ref_handle = pickform.data["picklist"]
ref_obj = Repository.objects.get(handle=ref_handle)
dji.add_repository_ref_default(parent_obj, ref_obj)
parent_obj.save_cache() # rebuild cache
return redirect("/%s/%s%s#tab-repositories" % (item, handle, build_search(request)))
else:
context["pickform"] = pickform
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "add":
repository = Repository(gramps_id=dji.get_next_id(Repository, "R"))
repositoryform = RepositoryForm(instance=repository)
repositoryform.model = repository
elif act in ["view", "edit"]:
repository = Repository.objects.get(handle=handle)
repositoryform = RepositoryForm(instance=repository)
repositoryform.model = repository
elif act == "save":
repository = Repository.objects.get(handle=handle)
repositoryform = RepositoryForm(request.POST, instance=repository)
repositoryform.model = repository
if repositoryform.is_valid():
update_last_changed(repository, request.user.username)
repository = repositoryform.save()
act = "view"
else:
act = "edit"
elif act == "create":
repository = Repository(handle=create_id())
repositoryform = RepositoryForm(request.POST, instance=repository)
repositoryform.model = repository
if repositoryform.is_valid():
update_last_changed(repository, request.user.username)
repository = repositoryform.save()
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_repository_ref_default(obj, repository)
obj.save_cache()
return redirect("/%s/%s#tab-repositories" % (item, handle))
act = "view"
else:
act = "add"
elif act == "delete":
repository = Repository.objects.get(handle=handle)
repository.delete()
return redirect("/repository/")
else:
raise Exception("Unhandled act: '%s'" % act)
context["repositoryform"] = repositoryform
context["object"] = repository
context["repository"] = repository
context["action"] = act
return render_to_response(view_template, context)

View File

@ -1,125 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed, build_search
from gramps.webapp.grampsdb.models import Source
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface
## Django Modules
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_source(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Source")
context["tviews"] = _("Sources")
context["action"] = "view"
view_template = "view_source_detail.html"
if handle == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
# Handle: edit, view, add, create, save, delete, share, save-share
if act == "share":
item, handle = add_to
context["pickform"] = PickForm("Pick source",
Source,
(),
request.POST)
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "save-share":
item, handle = add_to
pickform = PickForm("Pick source",
Source,
(),
request.POST)
if pickform.data["picklist"]:
parent_model = dji.get_model(item) # what model?
parent_obj = parent_model.objects.get(handle=handle) # to add
ref_handle = pickform.data["picklist"]
ref_obj = Source.objects.get(handle=ref_handle)
dji.add_source_ref_default(parent_obj, ref_obj)
parent_obj.save_cache() # rebuild cache
return redirect("/%s/%s%s#tab-sources" % (item, handle, build_search(request)))
else:
context["pickform"] = pickform
context["object_handle"] = handle
context["object_type"] = item
return render_to_response("pick.html", context)
elif act == "add":
source = Source(gramps_id=dji.get_next_id(Source, "S"))
sourceform = SourceForm(instance=source)
sourceform.model = source
elif act in ["view", "edit"]:
source = Source.objects.get(handle=handle)
sourceform = SourceForm(instance=source)
sourceform.model = source
elif act == "save":
source = Source.objects.get(handle=handle)
sourceform = SourceForm(request.POST, instance=source)
sourceform.model = source
if sourceform.is_valid():
update_last_changed(source, request.user.username)
source = sourceform.save()
dji.rebuild_cache(source)
act = "view"
else:
act = "edit"
elif act == "create":
source = Source(handle=create_id())
sourceform = SourceForm(request.POST, instance=source)
sourceform.model = source
if sourceform.is_valid():
update_last_changed(source, request.user.username)
source = sourceform.save()
dji.rebuild_cache(source)
if add_to:
raise Exception("Cannot add reference")
act = "view"
else:
act = "add"
elif act == "delete":
source = Source.objects.get(handle=handle)
source.delete()
return redirect("/source/")
else:
raise Exception("Unhandled act: '%s'" % act)
context["sourceform"] = sourceform
context["object"] = source
context["source"] = source
context["action"] = act
return render_to_response(view_template, context)

View File

@ -1,97 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Views for Person, Name, and Surname """
## Gramps Modules
from gramps.webapp.utils import _, boolean, update_last_changed
from gramps.webapp.grampsdb.models import Tag
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.libdjango import DjangoInterface
## Django Modules
from django.shortcuts import get_object_or_404, render_to_response, redirect
from django.template import Context, RequestContext
## Globals
dji = DjangoInterface()
def process_tag(request, context, handle, act, add_to=None): # view, edit, save
"""
Process act on person. Can return a redirect.
"""
context["tview"] = _("Tag")
context["tviews"] = _("Tags")
context["action"] = "view"
view_template = "view_tag_detail.html"
if handle == "add":
act = "add"
if "action" in request.POST:
act = request.POST.get("action")
# Handle: edit, view, add, create, save, delete
if act == "add":
tag = Tag()
tagform = TagForm(instance=tag)
tagform.model = tag
elif act in ["view", "edit"]:
tag = Tag.objects.get(handle=handle)
tagform = TagForm(instance=tag)
tagform.model = tag
elif act == "save":
tag = Tag.objects.get(handle=handle)
tagform = TagForm(request.POST, instance=tag)
tagform.model = tag
if tagform.is_valid():
update_last_changed(tag, request.user.username)
tag = tagform.save()
act = "view"
else:
act = "edit"
elif act == "create":
tag = Tag(handle=create_id())
tagform = TagForm(request.POST, instance=tag)
tagform.model = tag
if tagform.is_valid():
update_last_changed(tag, request.user.username)
tag = tagform.save()
if add_to:
item, handle = add_to
model = dji.get_model(item)
obj = model.objects.get(handle=handle)
dji.add_tag_ref_default(obj, tag)
obj.save_cache()
return redirect("/%s/%s#tab-tags" % (item, handle))
act = "view"
else:
act = "add"
elif act == "delete":
tag = Tag.objects.get(handle=handle)
tag.delete()
return redirect("/tag/")
else:
raise Exception("Unhandled act: '%s'" % act)
context["tagform"] = tagform
context["object"] = tag
context["tag"] = tag
context["action"] = act
return render_to_response(view_template, context)

File diff suppressed because it is too large Load Diff

View File

@ -1,219 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009-2012 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
"""
Creates a JSON representation of data for Django's fixture
architecture. We could have done this in Python, or SQL,
but this makes it useful for all Django-based backends
but still puts it into their syncdb API.
"""
import time
import os
os.environ["DJANGO_SETTINGS_MODULE"] = "default_settings"
import default_settings
from gramps.gen.config import config
from gramps.gen.lib.nametype import NameType
from gramps.gen.lib.nameorigintype import NameOriginType
from gramps.gen.lib.attrtype import AttributeType
from gramps.gen.lib.urltype import UrlType
from gramps.gen.lib.childreftype import ChildRefType
from gramps.gen.lib.repotype import RepositoryType
from gramps.gen.lib.placetype import PlaceType
from gramps.gen.lib.eventtype import EventType
from gramps.gen.lib.familyreltype import FamilyRelType
from gramps.gen.lib.srcmediatype import SourceMediaType
from gramps.gen.lib.eventroletype import EventRoleType
from gramps.gen.lib.notetype import NoteType
from gramps.gen.lib.styledtexttagtype import StyledTextTagType
from gramps.webapp.grampsdb.models import (GenderType, LdsType, LdsStatus,
NameFormatType, NameOriginType,
ThemeType)
def get_datamap(x):
"""
Returns (code, Name) for a Gramps type tuple.
"""
return (x[0],x[2])
print("[")
for table, entries in [("grampsdb.config",
[(("setting", "\"sitename\""),
("description", "\"site name of family tree\""),
("value_type", "\"str\""),
("value", "\"Gramps-Connect\"")),
(("setting", "\"db_version\""),
("description", "\"database scheme version\""),
("value_type", "\"str\""),
("value", "\"0.6.1\"")),
(("setting", "\"db_created\""),
("description", "\"database creation date/time\""),
("value_type", "\"str\""),
("value", ('"%s"' % time.strftime("%Y-%m-%d %H:%M")))),
]),
("grampsdb.report",
[(("name", '"Ahnentafel Report"'),
('gramps_id', '"R0001"'),
("handle", '"ancestor_report"'),
("report_type", '"report"')),
(("name", '"birthday_report"'),
('gramps_id', '"R0002"'),
("handle", '"birthday_report"'),
("report_type", '"report"')),
(("name", '"custom_text"'),
('gramps_id', '"R0003"'),
("handle", '"custom_text"'),
("report_type", '"report"')),
(("name", '"descend_report"'),
('gramps_id', '"R0004"'),
("handle", '"descend_report"'),
("report_type", '"report"')),
(("name", '"det_ancestor_report"'),
('gramps_id', '"R0005"'),
("handle", '"det_ancestor_report"'),
("report_type", '"report"')),
(("name", '"det_descendant_report"'),
('gramps_id', '"R0006"'),
("handle", '"det_descendant_report"'),
("report_type", '"report"')),
(("name", '"endofline_report"'),
('gramps_id', '"R0007"'),
("handle", '"endofline_report"'),
("report_type", '"report"')),
(("name", '"family_group"'),
('gramps_id', '"R0008"'),
("handle", '"family_group"'),
("report_type", '"report"')),
(("name", '"indiv_complete"'),
('gramps_id', '"R0009"'),
("handle", '"indiv_complete"'),
("report_type", '"report"')),
(("name", '"kinship_report"'),
('gramps_id', '"R0010"'),
("handle", '"kinship_report"'),
("report_type", '"report"')),
(("name", '"tag_report"'),
('gramps_id', '"R0011"'),
("handle", '"tag_report"'),
("report_type", '"report"')),
(("name", '"number_of_ancestors"'),
('gramps_id', '"R0012"'),
("handle", '"number_of_ancestors"'),
("report_type", '"report"')),
(("name", '"place_report"'),
('gramps_id', '"R0013"'),
("handle", '"place_report"'),
("report_type", '"report"')),
(("name", '"simple_book_title"'),
('gramps_id', '"R0014"'),
("handle", '"simple_book_title"'),
("report_type", '"report"')),
(("name", '"summary"'),
('gramps_id', '"R0015"'),
("handle", '"summary"'),
("report_type", '"report"')),
(("name", '"Export"'),
('gramps_id', '"R0016"'),
("handle", '"gedcom_export"'),
("options", '"off=ged"'),
("report_type", '"export"')),
(("name", '"Gramps XML Export"'),
('gramps_id', '"R0017"'),
("handle", '"ex_gpkg"'),
("options", '"off=gramps"'),
("report_type", '"export"')),
(("name", '"Import"'),
('gramps_id', '"R0018"'),
("handle", '"im_ged"'),
("options", '"iff=ged\\ni=http://arborvita.free.fr/Kennedy/Kennedy.ged"'),
("report_type", '"import"')),
(("name", '"Gramps package (portable XML) Import"'),
('gramps_id', '"R0019"'),
("handle", '"im_gpkg"'),
("options", '"iff=gramps\\ni=https://raw.githubusercontent.com/gramps-project/gramps/master/example/gramps/example.gramps"'),
("report_type", '"import"')),
])]:
entry_count = 0
for entry in entries:
print(" {")
print(" \"model\": \"%s\"," % table)
print(" \"pk\": %d," % (entry_count + 1))
print(" \"fields\":")
print(" {")
key_count = 0
for items in entry:
key, value = items
print((" \"%s\" : %s" % (key, value)), end=' ')
key_count += 1
if key_count < len(entry):
print(",")
else:
print()
print(" }")
print(" },")
entry_count += 1
pk = 4
for section in config.get_sections():
for setting in config.get_section_settings(section):
key = "%s.%s" % (section, setting)
value = config.get_default(key)
print(" {")
print(" \"model\": \"grampsdb.config\",")
print(" \"pk\": %d," % pk)
print(" \"fields\":")
print(" {")
print(" \"setting\" : \"%s\"," % key)
print(" \"value_type\" : \"%s\"," % type(value).__name__)
print(" \"value\": \"%s\"" % value)
print(" }")
print(" },", end=' ')
pk += 1
## Add the data for the type models:
type_models = [NameType, NameOriginType, AttributeType, UrlType, ChildRefType,
RepositoryType, EventType, FamilyRelType, SourceMediaType,
EventRoleType, NoteType, GenderType, LdsType, LdsStatus,
NameFormatType, StyledTextTagType, ThemeType, PlaceType]
for type in type_models:
count = 1
# Add each code:
for tuple in type._DATAMAP:
if len(tuple) == 3: # Gramps BSDDB style
val, name = get_datamap(tuple)
else: # NEW SQL based
val, name = tuple
print(" {")
print(" \"model\": \"grampsdb.%s\"," % type.__name__.lower())
print(" \"pk\": %d," % count)
print(" \"fields\":")
print(" {")
print(" \"val\" : %d," % val)
print(" \"name\": \"%s\"" % name)
print(" }")
print(" }", end=' ')
# if it is the last one of the last one, no comma
if type == type_models[-1] and count == len(type._DATAMAP):
print()
else:
print(",")
count += 1
print("]")

View File

@ -1,30 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
"""
Clears gramps data
"""
import os
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
import settings
from .grampsdb.models import models as dj
dj.clear_tables("primary", "secondary", "ref", "system")

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +0,0 @@
#!/usr/bin/env python
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Manage Django """
#------------------------------------------------------------------------
#
# Django Modules
#
#------------------------------------------------------------------------
# from django.core.management import execute_manager
# try:
# 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__)
# sys.exit(1)
# if __name__ == "__main__":
# execute_manager(settings)
import os, sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gramps.webapp.default_settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

View File

@ -1,13 +0,0 @@
import sys
class ModulesCheckpoint(object):
def __init__(self):
self.original = sys.modules.copy()
def reset(self):
# clear modules:
for key in list(sys.modules.keys()):
del(sys.modules[key])
# load previous:
for key in self.original:
sys.modules[key] = self.original[key]

View File

@ -1,143 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# webapp/reports.py
# imports for import/export:
from gramps.gen.dbstate import DbState
from gramps.cli.grampscli import CLIManager
from gramps.gen.plug import BasePluginManager
from gramps.cli.user import User as GUser # gramps user
import os
# Example for running a report:
# ------------------------------
# from gramps.cli.plug import run_report
# from django.conf import settings
# import webapp.settings as default_settings
# try:
# settings.configure(default_settings)
# except:
# pass
# import djangodb
# db = djangodb.DbDjango()
# run_report(db, "ancestor_report", off="txt", of="ar.txt", pid="I0363")
def get_plugin_options(db, pid):
"""
Get the default options and help for this plugin.
"""
dbstate = DbState()
climanager = CLIManager(dbstate, setloader=False, user=GUser()) # do not load db_loader
climanager.do_reg_plugins(dbstate, None)
pmgr = BasePluginManager.get_instance()
pdata = pmgr.get_plugin(pid)
if hasattr(pdata, "optionclass") and pdata.optionclass:
mod = pmgr.load_plugin(pdata)
optionclass = eval("mod." + pdata.optionclass)
optioninstance = optionclass("Name", db)
optioninstance.load_previous_values()
return optioninstance.options_dict, optioninstance.options_help
else:
return {}, {}
def import_file(db, filename, user):
"""
Import a file (such as a GEDCOM file) into the given db.
>>> import_file(DbDjango(), "/home/user/Untitled_1.ged", User())
"""
from .grampsdb.models import Person
dbstate = DbState()
climanager = CLIManager(dbstate, setloader=False, user=user) # do not load db_loader
climanager.do_reg_plugins(dbstate, None)
pmgr = BasePluginManager.get_instance()
(name, ext) = os.path.splitext(os.path.basename(filename))
format = ext[1:].lower()
import_list = pmgr.get_reg_importers()
for pdata in import_list:
if format == pdata.extension:
mod = pmgr.load_plugin(pdata)
if not mod:
for item in pmgr.get_fail_list():
name, error_tuple, pdata = item
# (filename, (exception-type, exception, traceback), pdata)
etype, exception, traceback = error_tuple
print("ERROR:", name, exception)
return False
import_function = getattr(mod, pdata.import_function)
retval = import_function(db, filename, user)
return retval
return False
def download(url, filename=None):
from urllib.request import Request, urlopen
from urllib.parse import urlsplit
import shutil
def getFilename(url,openUrl):
if 'Content-Disposition' in openUrl.info():
# If the response has Content-Disposition, try to get filename from it
cd = dict([x.strip().split('=') if '=' in x else (x.strip(),'')
for x in openUrl.info().split(';')])
if 'filename' in cd:
fname = cd['filename'].strip("\"'")
if fname: return fname
# if no filename was found above, parse it out of the final URL.
return os.path.basename(urlsplit(openUrl.url)[2])
r = urlopen(Request(url))
success = None
try:
filename = filename or "/tmp/%s" % getFilename(url,r)
with open(filename, 'wb') as f:
shutil.copyfileobj(r,f)
success = filename
finally:
r.close()
return success
def export_file(db, filename, user):
"""
Export the db to a file (such as a GEDCOM file).
>>> export_file(DbDjango(), "/home/user/Untitled_1.ged", User())
"""
dbstate = DbState()
climanager = CLIManager(dbstate, setloader=False, user=user) # do not load db_loader
climanager.do_reg_plugins(dbstate, None)
pmgr = BasePluginManager.get_instance()
(name, ext) = os.path.splitext(os.path.basename(filename))
format = ext[1:].lower()
export_list = pmgr.get_reg_exporters()
for pdata in export_list:
if format == pdata.extension:
mod = pmgr.load_plugin(pdata)
if not mod:
for item in pmgr.get_fail_list():
name, error_tuple, pdata = item
etype, exception, traceback = error_tuple
print("ERROR:", name, exception)
return False
export_function = getattr(mod, pdata.export_function)
export_function(db, filename, user)
return True
return False

View File

@ -1,106 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#### This sets up Django so you can interact with it via the Python
#### command line.
#### Start with something like:
#### $ PYTHONPATH=..:../plugins/lib python -i shell.py
#### >>> Person.objects.all()
import os
os.environ['GRAMPS_RESOURCES'] = os.path.dirname(os.path.abspath(".."))
pystartup = os.path.expanduser("~/.pystartup")
if not os.path.exists(pystartup):
fp = file(pystartup, "w")
fp.write("""
import atexit
import os
import readline
import rlcompleter
import sys
# change autocomplete to tab
readline.parse_and_bind("tab: complete")
historyPath = os.path.expanduser("~/.pyhistory")
def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)
if os.path.exists(historyPath):
readline.read_history_file(historyPath)
atexit.register(save_history)
# anything not deleted (sys and os) will remain in the interpreter session
del atexit, readline, rlcompleter, save_history, historyPath""")
fp.close()
with open(pystartup) as f:
code = compile(f.read(), pystartup, 'exec')
exec(code, globals(), locals())
from django.conf import settings
from gramps.webapp import default_settings
try:
settings.configure(default_settings)
except RuntimeError:
# already configured; ignore
pass
# For Django 1.6:
import django
django.setup()
from gramps.webapp.grampsdb.models import *
from gramps.webapp.grampsdb.forms import *
from gramps.webapp.djangodb import DbDjango
from gramps.webapp.reports import import_file, export_file
from gramps.webapp.libdjango import DjangoInterface, totime, todate
from gramps.gen.datehandler import displayer, parser
from gramps.webapp.utils import StyledNoteFormatter, parse_styled_text
from gramps.gen.lib import StyledText
from gramps.cli.user import User as GUser # gramps user
from django.db.models import Q
db = DbDjango()
db.load(os.path.abspath(os.path.dirname(__file__)))
dd = displayer.display
dp = parser.parse
#import_file(db,
# "/home/dblank/gramps/trunk/example/gramps/data.gramps",
# GUser())
#snf = StyledNoteFormatter(db)
#for n in Note.objects.all():
# note = db.get_note_from_handle(n.handle)
# print snf.format(note)
#note = Note.objects.get(handle="aef30789d3d2090abe2")
#genlibnote = db.get_note_from_handle(note.handle)
#html_text = snf.format(genlibnote)
## FIXME: this looks wrong:
#print html_text
#print parse_styled_text(html_text)
##st = StyledText(note.text, dji.get_note_markup(note))

View File

@ -1 +0,0 @@
PYTHONPATH=../.. python3 -i shell.py

View File

@ -1,130 +0,0 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" Url handler """
#------------------------------------------------------------------------
#
# Python Modules
#
#------------------------------------------------------------------------
import os
#------------------------------------------------------------------------
#
# Django and Gramps Modules
#
#------------------------------------------------------------------------
from gramps.gen.const import IMAGE_DIR, ROOT_DIR, DATA_DIR
from django.conf.urls import patterns, url, include
from django.contrib import admin
admin.autodiscover()
from gramps.webapp.grampsdb.views import *
urlpatterns = patterns('',
# Specific matches first:
url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += patterns('',
# Static serves! DANGEROUS in production:
(r'^styles/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': DATA_DIR,
# os.path.join(ROOT_DIR, "plugins", "webstuff"),
'show_indexes': True},
),
(r'^images/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': IMAGE_DIR,
'show_indexes': True},
),
# Django 1.5.4
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/usr/share/pyshared/django/contrib/admin/static/',
'show_indexes': True},
),
# Django 1.5.4
)
# The rest will match views:
urlpatterns += patterns('',
(r'^$', main_page),
## Prior to django 1.5, use this:
##(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to',
##{'url': '/styles/images/favicon.ico'}),
# Django 1.5.4:
(r'^favicon\.ico$', 'django.shortcuts.redirect',
{'url': '/styles/images/favicon.ico'}),
(r'^user/$', user_page),
(r'^json/$', process_json_request),
(r'^user/(\w+)/$', user_page),
(r'^browse/$', browse_page),
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', logout_page),
(r'^(?P<view>(\w+))/$',
view_list), # /view/
(r'^(?P<view>(\w+))/add$',
action,
{"handle": None, "act": "add"}), # /view/add
(r'^(?P<view>(\w+))/add/(?P<item>(\w+))/(?P<handle>(\w+))$',
add_to), # /view/add/item/handle
(r'^(?P<view>(\w+))/share/(?P<item>(\w+))/(?P<handle>(\w+))$',
add_share), # /view/share/item/handle
(r'^(?P<view>(\w+))/(?P<handle>(\w+))/$', action,
{"act": "view"}), # /view/handle/
(r'^(?P<view>(\w+))/(?P<handle>(\w+))/(?P<act>(\w+))$',
action), # /view/handle/action
(r'^(?P<ref_by>(\w+))/(?P<handle>(\w+))/reference/(?P<ref_to>(\w+))/(?P<order>(\w+))$',
process_reference), # /view/handle/reference/item/order
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))$', process_name),
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))/(?P<act>(\w+))$',
process_name),
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))/surname/(?P<sorder>(\w+))$',
process_surname),
(r'^person/(?P<handle>(\w+))/name/(?P<order>(\w+))/surname/(?P<sorder>(\w+))/(?P<act>(\w+))$',
process_surname),
(r'^family/(?P<handle>(\w+))/(?P<act>(\w+))/child/(?P<child>(\w+))$', process_child),
## (r'^profile/(?P<position>(\w+)/)$', ),
(r'^(?P<view>(\w+))/(?P<handle>(\w+))/(?P<act>(\w+))/(?P<item>(\w+))/(?P<index>(\w+))$',
process_list_item),
(r'^note/(?P<action>(\w+))/person/(?P<handle>(\w+))/name/(?P<order>(\w+))$',
process_note_on_name),
)
# In urls:
# urlpatterns = patterns('',
# url(r'^archive/(\d{4})/$', archive, name="full-archive"),
# url(r'^archive-summary/(\d{4})/$', archive, {'summary': True}, "arch-summary"),
# )
# In template:
# {% url arch-summary 1945 %}
# {% url full-archive 2007 %}
#{% url path.to.view as the_url %}
#{% if the_url %}
# <a href="{{ the_url }}">Link to optional stuff</a>
#{% endif %}
# In code:
#from django.core.urlresolvers import reverse
#
#def myview(request):
# return HttpResponseRedirect(reverse('arch-summary', args=[1945]))

File diff suppressed because it is too large Load Diff

View File

@ -515,21 +515,6 @@ gramps/test/test/test_util_test.py
gramps/test/test_util.py
gramps/test/utils_test.py
#
# webapp
#
gramps/webapp/connection.py
gramps/webapp/context.py
gramps/webapp/dbdjango.py
gramps/webapp/grampsdb/admin.py
gramps/webapp/grampsdb/forms.py
gramps/webapp/grampsdb/__init__.py
gramps/webapp/grampsdb/models.py
gramps/webapp/grampsdb/profile.py
gramps/webapp/grampsdb/templatetags/__init__.py
gramps/webapp/grampsdb/templatetags/my_tags.py
gramps/webapp/grampsdb/view/__init__.py
gramps/webapp/grampsdb/view/png.py
#
# Glade files
#
gramps/gui/glade/gramps.glade

View File

@ -61,11 +61,6 @@ if svem_flag in sys.argv:
# Die, setuptools, die.
sys.argv.remove(svem_flag)
server = False
if '--server' in sys.argv:
sys.argv.remove('--server')
server = True
# check if the resourcepath option is used and store the path
# this is for packagers that build out of the source tree
# other options to setup.py are passed through
@ -368,15 +363,8 @@ package_gui = ['gramps.gui',
'gramps.gui.views.treemodels',
'gramps.gui.widgets',
]
package_webapp = ['gramps.webapp',
'gramps.webapp.grampsdb',
'gramps.webapp.grampsdb.templatetags',
'gramps.webapp.grampsdb.view',
]
if server:
packages = package_core + package_webapp
else:
packages = package_core + package_gui
packages = package_core + package_gui
#-------------------------------------------------------------------------
#
@ -399,16 +387,11 @@ for (dirpath, dirnames, filenames) in os.walk(basedir):
#we add to data_list so glade , xml, files are found, we don't need the gramps/ part
package_data_core.append(dirpath[7:] + '/' + dirname + '/*.glade')
package_data_core.append(dirpath[7:] + '/' + dirname + '/*.xml')
package_data_core.append('gen/utils/resource-path')
package_data_gui = ['gui/glade/*.glade']
package_data_webapp = ['webapp/*.sql', 'webapp/grampsdb/sql/*.sql']
if server:
package_data = package_data_core + package_data_webapp
else:
package_data = package_data_core + package_data_gui
package_data = package_data_core + package_data_gui
#-------------------------------------------------------------------------
#
@ -461,18 +444,11 @@ data_files_gui.append(('share/gramps/images/hicolor/22x22/actions', ICON_22))
data_files_gui.append(('share/gramps/images/hicolor/48x48/actions', ICON_48))
data_files_gui.append(('share/gramps/images/hicolor/scalable/actions', ICON_SC))
data_files_webapp = []
TEMPLATE_FILES = glob.glob(os.path.join('data/templates', '*.html'))
data_files_webapp.append(('share/gramps/templates', TEMPLATE_FILES))
ADMIN_FILES = glob.glob(os.path.join('data/templates/admin', '*.html'))
data_files_webapp.append(('share/gramps/templates/admin', ADMIN_FILES))
REG_FILES = glob.glob(os.path.join('data/templates/registration', '*.html'))
data_files_webapp.append(('share/gramps/templates/registration', REG_FILES))
if server:
data_files = data_files_core + data_files_webapp
else:
data_files = data_files_core + data_files_gui
data_files = data_files_core + data_files_gui
#-------------------------------------------------------------------------
#