[TASK] Big unicode cleanup.
This commit is contained in:
parent
9b06e3aac6
commit
13058a41f7
|
@ -10,12 +10,12 @@ from frontend.views import IndexView, ProjectView, ProjectUpdateView, ProjectPer
|
||||||
|
|
||||||
urlpatterns = patterns(
|
urlpatterns = patterns(
|
||||||
'',
|
'',
|
||||||
url(r'^$', IndexView.as_view(), name='frontend-index'),
|
url(r'^$', IndexView.as_view(), name=u'frontend-index'),
|
||||||
url(r'^project/$', ProjectView.as_view(), name='frontend-projects'),
|
url(r'^project/$', ProjectView.as_view(), name=u'frontend-projects'),
|
||||||
url(r'^project/(?P<project_id>\d+)/update$', ProjectUpdateView.as_view(), name='frontend-project-update'),
|
url(r'^project/(?P<project_id>\d+)/update$', ProjectUpdateView.as_view(), name=u'frontend-project-update'),
|
||||||
url(r'^project/(?P<project_id>\d+)/map/person$', ProjectPersonView.as_view(), name='frontend-project-view-person'),
|
url(r'^project/(?P<project_id>\d+)/map/person$', ProjectPersonView.as_view(), name=u'frontend-project-view-person'),
|
||||||
url(r'^project/(?P<project_id>\d+)/map/person/(?P<person_uuid>[\w\d-]+)$', ProjectMapPersonView.as_view(), name='frontend-project-map-person'),
|
url(r'^project/(?P<project_id>\d+)/map/person/(?P<person_uuid>[\w\d-]+)$', ProjectMapPersonView.as_view(), name=u'frontend-project-map-person'),
|
||||||
url(r'^login/$', login_wrap, name='frontend-login'),
|
url(r'^login/$', login_wrap, name=u'frontend-login'),
|
||||||
url(r'^logout/$', logout_wrap, name='frontend-logout'),
|
url(r'^logout/$', logout_wrap, name=u'frontend-logout'),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
)
|
)
|
|
@ -9,42 +9,42 @@ class NewProjectForm(forms.ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(NewProjectForm, self).__init__(*args, **kwargs)
|
super(NewProjectForm, self).__init__(*args, **kwargs)
|
||||||
self.helper = FormHelper()
|
self.helper = FormHelper()
|
||||||
self.helper.form_class = 'form-horizontal'
|
self.helper.form_class = u'form-horizontal'
|
||||||
self.helper.label_class = 'col-lg-2'
|
self.helper.label_class = u'col-lg-2'
|
||||||
self.helper.field_class = 'col-lg-4'
|
self.helper.field_class = u'col-lg-4'
|
||||||
self.helper.form_method = 'post'
|
self.helper.form_method = u'post'
|
||||||
self.helper.layout = Layout(
|
self.helper.layout = Layout(
|
||||||
'name',
|
u'name',
|
||||||
'description',
|
u'description',
|
||||||
Submit('send', 'Create', css_class='btn-default')
|
Submit(u'send', u'Create', css_class=u'btn-default')
|
||||||
)
|
)
|
||||||
|
|
||||||
name = forms.CharField(
|
name = forms.CharField(
|
||||||
label="Name",
|
label=u"Name",
|
||||||
max_length=255,
|
max_length=255,
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
description = forms.CharField(
|
description = forms.CharField(
|
||||||
label="Description",
|
label=u"Description",
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Project
|
model = Project
|
||||||
fields = ['name', 'description']
|
fields = [u'name', u'description']
|
||||||
|
|
||||||
class FileUploadForm(forms.Form):
|
class FileUploadForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(FileUploadForm, self).__init__(*args, **kwargs)
|
super(FileUploadForm, self).__init__(*args, **kwargs)
|
||||||
self.helper = FormHelper()
|
self.helper = FormHelper()
|
||||||
self.helper.form_class = 'form-horizontal'
|
self.helper.form_class = u'form-horizontal'
|
||||||
self.helper.label_class = 'col-lg-2'
|
self.helper.label_class = u'col-lg-2'
|
||||||
self.helper.field_class = 'col-lg-4'
|
self.helper.field_class = u'col-lg-4'
|
||||||
self.helper.form_method = 'post'
|
self.helper.form_method = u'post'
|
||||||
self.helper.layout = Layout(
|
self.helper.layout = Layout(
|
||||||
'file',
|
u'file',
|
||||||
Submit('send', 'Upload', css_class='btn-default')
|
Submit(u'send', u'Upload', css_class=u'btn-default')
|
||||||
)
|
)
|
||||||
|
|
||||||
file = forms.FileField()
|
file = forms.FileField()
|
||||||
|
@ -54,17 +54,17 @@ class PersonMapForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PersonMapForm, self).__init__(*args, **kwargs)
|
super(PersonMapForm, self).__init__(*args, **kwargs)
|
||||||
self.helper = FormHelper()
|
self.helper = FormHelper()
|
||||||
self.helper.form_class = 'form-horizontal'
|
self.helper.form_class = u'form-horizontal'
|
||||||
self.helper.label_class = 'col-lg-2'
|
self.helper.label_class = u'col-lg-2'
|
||||||
self.helper.field_class = 'col-lg-4'
|
self.helper.field_class = u'col-lg-4'
|
||||||
self.helper.form_method = 'post'
|
self.helper.form_method = u'post'
|
||||||
self.helper.layout = Layout(
|
self.helper.layout = Layout(
|
||||||
'action',
|
u'action',
|
||||||
'global_identity',
|
u'global_identity',
|
||||||
Submit('skip', 'Skip', css_class='btn-default'),
|
Submit(u'skip', u'Skip', css_class=u'btn-default'),
|
||||||
Submit('save-continue', 'Save and continue', css_class='btn-default'),
|
Submit(u'save-continue', u'Save and continue', css_class=u'btn-default'),
|
||||||
)
|
)
|
||||||
|
|
||||||
action = forms.ChoiceField(choices=[('new', 'Create new global Identity'), ('existing', 'Map to existing identity')], initial='new', widget=forms.RadioSelect())
|
action = forms.ChoiceField(choices=[(u'new', u'Create new global Identity'), (u'existing', u'Map to existing identity')], initial=u'new', widget=forms.RadioSelect())
|
||||||
global_identity = forms.ModelChoiceField(queryset=PersonGlobalIdentity.objects.all(), required=False)
|
global_identity = forms.ModelChoiceField(queryset=PersonGlobalIdentity.objects.all(), required=False)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
class Project(models.Model):
|
class Project(models.Model):
|
||||||
""" Model representing a citavi project. """
|
""" Model representing a citavi project. """
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
|
@ -10,12 +9,12 @@ class Project(models.Model):
|
||||||
associated_filename = models.CharField(max_length=255, blank=True, null=True)
|
associated_filename = models.CharField(max_length=255, blank=True, null=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
repr = self.name
|
temp = unicode(self.name)
|
||||||
if self.associated_filename:
|
if self.associated_filename:
|
||||||
repr += " (" + self.associated_filename + ")"
|
temp += u" (" + unicode(self.associated_filename) + u")"
|
||||||
else:
|
else:
|
||||||
repr += " (empty)"
|
temp += u" (empty)"
|
||||||
return repr
|
return temp
|
||||||
|
|
||||||
|
|
||||||
class PersonGlobalIdentity(models.Model):
|
class PersonGlobalIdentity(models.Model):
|
||||||
|
@ -24,8 +23,9 @@ class PersonGlobalIdentity(models.Model):
|
||||||
# TODO: Extend this for further stuff - maybe vivo external url or something?
|
# TODO: Extend this for further stuff - maybe vivo external url or something?
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
repr = "<PersonGlobalIdentity ID=" + str(self.id) + ", type=" + self.type + ">"
|
from service.Mapper import PersonMapper
|
||||||
return repr
|
pm = PersonMapper()
|
||||||
|
return u"<PersonGlobalIdentity repr=" + pm.get_representation_for_global_identity(self) + u" ID=" + unicode(self.id) + u", type=" + unicode(self.type) + u">"
|
||||||
|
|
||||||
|
|
||||||
class CitaviProjectIdentity(models.Model):
|
class CitaviProjectIdentity(models.Model):
|
||||||
|
@ -36,5 +36,4 @@ class CitaviProjectIdentity(models.Model):
|
||||||
preferred = models.BooleanField()
|
preferred = models.BooleanField()
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
repr = "<CitaviProjectIdentity project=" + str(self.project) + ", citavi_uuid=" + self.citavi_uuid + ", global_identity=" + str(self.global_identity) + ", preferred=" + str(self.preferred) + ">"
|
return u"<CitaviProjectIdentity project=" + unicode(self.project) + u", citavi_uuid=" + unicode(self.citavi_uuid) + u", global_identity=" + unicode(self.global_identity) + u", preferred=" + unicode(self.preferred) + u">"
|
||||||
return repr
|
|
||||||
|
|
|
@ -11,11 +11,6 @@
|
||||||
<p><strong>Description:</strong> {{project.description}}</h3>
|
<p><strong>Description:</strong> {{project.description}}</h3>
|
||||||
<p><strong>Current uploaded database filename:</strong> {{project.associated_filename}}</p>
|
<p><strong>Current uploaded database filename:</strong> {{project.associated_filename}}</p>
|
||||||
|
|
||||||
<!--
|
|
||||||
<h3>Upload the new database version</h3>
|
|
||||||
<p>{% crispy form %}</p>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<h3>Stats</h3>
|
<h3>Stats</h3>
|
||||||
<p>
|
<p>
|
||||||
<strong>Mapped:</strong> {{mapped_persons|length}}<br>
|
<strong>Mapped:</strong> {{mapped_persons|length}}<br>
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
<td>{{project.description}}</td>
|
<td>{{project.description}}</td>
|
||||||
<td>{{project.associated_filename}}</td>
|
<td>{{project.associated_filename}}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{% url 'frontend-project-update' project.id %}">Update project</a>
|
<a href="{% url 'frontend-project-update' project.id %}">Update</a>,
|
||||||
<a href="{% url 'frontend-project-view-person' project.id %}">Persons</a>
|
<a href="{% url 'frontend-project-view-person' project.id %}">Map</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -17,25 +17,25 @@ from frontend.forms import NewProjectForm, FileUploadForm, PersonMapForm
|
||||||
|
|
||||||
from frontend.models import Project
|
from frontend.models import Project
|
||||||
|
|
||||||
FRONTEND_PAGE_NAME = 'Citavi Mapper'
|
FRONTEND_PAGE_NAME = u'Citavi Mapper'
|
||||||
|
|
||||||
# Login wrapper functions
|
# Login wrapper functions
|
||||||
def login_wrap(*args, **kwargs):
|
def login_wrap(*args, **kwargs):
|
||||||
""" Wrapper function for login page. """
|
""" Wrapper function for login page. """
|
||||||
kwargs['extra_context'] = {
|
kwargs[u'extra_context'] = {
|
||||||
'page': {
|
u'page': {
|
||||||
'name': FRONTEND_PAGE_NAME,
|
u'name': FRONTEND_PAGE_NAME,
|
||||||
'title': 'Login'
|
u'title': 'Login'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return login(*args, **kwargs)
|
return login(*args, **kwargs)
|
||||||
|
|
||||||
def logout_wrap(*args, **kwargs):
|
def logout_wrap(*args, **kwargs):
|
||||||
""" Wrapper function for logout page. """
|
""" Wrapper function for logout page. """
|
||||||
kwargs['extra_context'] = {
|
kwargs[u'extra_context'] = {
|
||||||
'page': {
|
u'page': {
|
||||||
'name': FRONTEND_PAGE_NAME,
|
u'name': FRONTEND_PAGE_NAME,
|
||||||
'title': 'Logout'
|
u'title': 'Logout'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return logout(*args, **kwargs)
|
return logout(*args, **kwargs)
|
||||||
|
@ -44,9 +44,9 @@ def logout_wrap(*args, **kwargs):
|
||||||
# My base classes for views
|
# My base classes for views
|
||||||
class MyViewMixin(object):
|
class MyViewMixin(object):
|
||||||
""" Basic view mixin to add global variables to all templates. """
|
""" Basic view mixin to add global variables to all templates. """
|
||||||
template_name = 'base.html'
|
template_name = u'base.html'
|
||||||
page_name = FRONTEND_PAGE_NAME
|
page_name = FRONTEND_PAGE_NAME
|
||||||
page_title = 'BASE'
|
page_title = u'BASE'
|
||||||
|
|
||||||
def get_page_data(self):
|
def get_page_data(self):
|
||||||
return {
|
return {
|
||||||
|
@ -95,18 +95,18 @@ class ProtectedUpdateView(LoggedInMixin, MyUpdateView):
|
||||||
|
|
||||||
# Actual Views
|
# Actual Views
|
||||||
class IndexView(ProtectedTemplateView):
|
class IndexView(ProtectedTemplateView):
|
||||||
template_name = 'index.html'
|
template_name = u'index.html'
|
||||||
page_title = 'Index'
|
page_title = u'Index'
|
||||||
|
|
||||||
|
|
||||||
class ProjectView(ProtectedFormView):
|
class ProjectView(ProtectedFormView):
|
||||||
template_name = 'projects.html'
|
template_name = u'projects.html'
|
||||||
page_title = 'Projects'
|
page_title = u'Projects'
|
||||||
form_class = NewProjectForm
|
form_class = NewProjectForm
|
||||||
success_url = '/project'
|
success_url = u'/project'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
kwargs[u'projects'] = Project.objects.order_by('id')
|
kwargs[u'projects'] = Project.objects.order_by(u'id')
|
||||||
return super(ProjectView, self).get_context_data(**kwargs)
|
return super(ProjectView, self).get_context_data(**kwargs)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
@ -115,11 +115,11 @@ class ProjectView(ProtectedFormView):
|
||||||
|
|
||||||
|
|
||||||
class ProjectUpdateView(ProtectedFormView, SingleObjectMixin):
|
class ProjectUpdateView(ProtectedFormView, SingleObjectMixin):
|
||||||
template_name = 'project/update.html'
|
template_name = u'project/update.html'
|
||||||
page_title = 'Update project'
|
page_title = u'Update project'
|
||||||
form_class = FileUploadForm
|
form_class = FileUploadForm
|
||||||
|
|
||||||
success_url = '/project/'
|
success_url = u'/project/'
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
self.project_id = kwargs[u'project_id']
|
self.project_id = kwargs[u'project_id']
|
||||||
|
@ -128,16 +128,17 @@ class ProjectUpdateView(ProtectedFormView, SingleObjectMixin):
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
self.project_id = kwargs[u'project_id']
|
self.project_id = kwargs[u'project_id']
|
||||||
self.success_url = self.success_url + self.project_id + '/update'
|
self.object = Project.objects.get(pk=self.project_id)
|
||||||
|
self.success_url = self.success_url + self.project_id + u'/update'
|
||||||
return super(ProjectUpdateView, self).post(request, *args, **kwargs)
|
return super(ProjectUpdateView, self).post(request, *args, **kwargs)
|
||||||
|
|
||||||
def form_valid(self, form, *args, **kwargs):
|
def form_valid(self, form, *args, **kwargs):
|
||||||
""" This form_valid handles the file upload. """
|
""" This form_valid handles the file upload. """
|
||||||
original_file = form.files[u'file']
|
original_file = form.files[u'file']
|
||||||
original_filename = str(original_file)
|
original_filename = unicode(original_file)
|
||||||
original_contentfile = ContentFile(original_file.read())
|
original_contentfile = ContentFile(original_file.read())
|
||||||
""" Put file into temporary folder for analysis """
|
""" Put file into temporary folder for analysis """
|
||||||
target_filename = 'tmp/project_' + str(self.project_id) + '.ctt4'
|
target_filename = u'tmp/project_' + unicode(self.project_id) + u'.ctt4'
|
||||||
relative_path = default_storage.save(target_filename, original_contentfile)
|
relative_path = default_storage.save(target_filename, original_contentfile)
|
||||||
temp_sqlite = os.path.join(settings.MEDIA_ROOT, relative_path)
|
temp_sqlite = os.path.join(settings.MEDIA_ROOT, relative_path)
|
||||||
|
|
||||||
|
@ -154,7 +155,7 @@ class ProjectUpdateView(ProtectedFormView, SingleObjectMixin):
|
||||||
""" TODO: Put up an error message or something. """
|
""" TODO: Put up an error message or something. """
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
target_filename = 'citavi/project_' + str(self.project_id) + '.ctt4'
|
target_filename = u'citavi/project_' + unicode(self.project_id) + u'.ctt4'
|
||||||
""" Remove eventually pre-existing citavi file. """
|
""" Remove eventually pre-existing citavi file. """
|
||||||
if default_storage.exists(target_filename):
|
if default_storage.exists(target_filename):
|
||||||
default_storage.delete(target_filename)
|
default_storage.delete(target_filename)
|
||||||
|
@ -177,11 +178,11 @@ class ProjectUpdateView(ProtectedFormView, SingleObjectMixin):
|
||||||
|
|
||||||
|
|
||||||
class ProjectPersonView(ProtectedFormView, SingleObjectMixin):
|
class ProjectPersonView(ProtectedFormView, SingleObjectMixin):
|
||||||
template_name = 'project/view-person.html'
|
template_name = u'project/view-person.html'
|
||||||
page_title = 'Person List View'
|
page_title = u'Person List View'
|
||||||
form_class = FileUploadForm
|
form_class = FileUploadForm
|
||||||
|
|
||||||
success_url = '/projects/'
|
success_url = u'/project/'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
project = self.object
|
project = self.object
|
||||||
|
@ -207,11 +208,11 @@ class ProjectPersonView(ProtectedFormView, SingleObjectMixin):
|
||||||
|
|
||||||
|
|
||||||
class ProjectMapPersonView(ProtectedFormView, SingleObjectMixin):
|
class ProjectMapPersonView(ProtectedFormView, SingleObjectMixin):
|
||||||
template_name = 'project/map-person.html'
|
template_name = u'project/map-person.html'
|
||||||
page_title = 'Person Mapping'
|
page_title = u'Person Mapping'
|
||||||
form_class = PersonMapForm
|
form_class = PersonMapForm
|
||||||
|
|
||||||
success_url = '/project'
|
success_url = u'/project'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
project = self.object
|
project = self.object
|
||||||
|
@ -239,11 +240,11 @@ class ProjectMapPersonView(ProtectedFormView, SingleObjectMixin):
|
||||||
pm = Mapper.PersonMapper()
|
pm = Mapper.PersonMapper()
|
||||||
person = pm.get_person_by_uuid(self.object, self.person_uuid)
|
person = pm.get_person_by_uuid(self.object, self.person_uuid)
|
||||||
|
|
||||||
print str(form.cleaned_data)
|
print unicode(form.cleaned_data)
|
||||||
# TODO: do mapping according to parameters, override success_url to point to next person!
|
# TODO: do mapping according to parameters, override success_url to point to next person!
|
||||||
if form.cleaned_data['action'] == 'new':
|
if form.cleaned_data[u'action'] == u'new':
|
||||||
pm.create_new_identity(self.object, person)
|
pm.create_new_identity(self.object, person)
|
||||||
elif form.cleaned_data['action'] == 'skip':
|
elif form.cleaned_data[u'action'] == u'skip':
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return super(ProjectMapPersonView, self).form_valid(form)
|
return super(ProjectMapPersonView, self).form_valid(form)
|
||||||
|
|
|
@ -31,19 +31,19 @@ class Project():
|
||||||
except:
|
except:
|
||||||
self._is_error = True
|
self._is_error = True
|
||||||
# TODO: better error handling!
|
# TODO: better error handling!
|
||||||
print "An error occured within a get_persons call!"
|
print u"An error occured within a get_persons call!"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_person_by_uuid(self, uuid):
|
def get_person_by_uuid(self, uuid):
|
||||||
""" Returns a person from the Citavi project by their uuid. """
|
""" Returns a person from the Citavi project by their uuid. """
|
||||||
try:
|
try:
|
||||||
person_class = self._sa_sqlite_autobase.classes.Person
|
person_class = self._sa_sqlite_autobase.classes.Person
|
||||||
citavi_person = self._sa_sqlite_session.query(person_class).filter('ID=\'' + str(uuid) + '\'').all()
|
citavi_person = self._sa_sqlite_session.query(person_class).filter(u'ID=\'' + unicode(uuid) + u'\'').all()
|
||||||
return citavi_person[0]
|
return citavi_person[0]
|
||||||
except:
|
except:
|
||||||
self._is_error = True
|
self._is_error = True
|
||||||
# TODO: better error handling!
|
# TODO: better error handling!
|
||||||
print "An error occured within a get_person_by_uuid call!"
|
print u"An error occured within a get_person_by_uuid call!"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
|
@ -59,7 +59,7 @@ class Project():
|
||||||
def _open(self):
|
def _open(self):
|
||||||
""" Internal method to open a citavi project file. """
|
""" Internal method to open a citavi project file. """
|
||||||
try:
|
try:
|
||||||
self._sa_sqlite_engine = create_engine('sqlite+pysqlite:///' + self.sqlite_file)
|
self._sa_sqlite_engine = create_engine(u'sqlite+pysqlite:///' + self.sqlite_file)
|
||||||
self._sa_sqlite_session = Session(self._sa_sqlite_engine)
|
self._sa_sqlite_session = Session(self._sa_sqlite_engine)
|
||||||
self._sa_sqlite_meta = MetaData(bind=self._sa_sqlite_engine)
|
self._sa_sqlite_meta = MetaData(bind=self._sa_sqlite_engine)
|
||||||
self._sa_sqlite_meta.reflect()
|
self._sa_sqlite_meta.reflect()
|
||||||
|
@ -96,7 +96,7 @@ class ProjectManager():
|
||||||
self._projects.clear()
|
self._projects.clear()
|
||||||
|
|
||||||
def get_path_for_project_id(self, project_id):
|
def get_path_for_project_id(self, project_id):
|
||||||
return 'media/citavi/project_' + str(project_id) + '.ctt4'
|
return u'media/citavi/project_' + unicode(project_id) + u'.ctt4'
|
||||||
|
|
||||||
def _add_project(self, project_id):
|
def _add_project(self, project_id):
|
||||||
""" Internal method to add a Project instance if not existing. """
|
""" Internal method to add a Project instance if not existing. """
|
||||||
|
|
|
@ -26,3 +26,7 @@ class PersonIdentityManager():
|
||||||
def get_mapped_identities_for_project(self, project_instance):
|
def get_mapped_identities_for_project(self, project_instance):
|
||||||
""" Returns all existing (mapped) identies for a given project. """
|
""" Returns all existing (mapped) identies for a given project. """
|
||||||
return CitaviProjectIdentity.objects.filter(project=project_instance).all()
|
return CitaviProjectIdentity.objects.filter(project=project_instance).all()
|
||||||
|
|
||||||
|
def get_citavi_identity_by_global_identity(self, global_identity):
|
||||||
|
""" Returns the preferred citavi identity based on their global identity. """
|
||||||
|
return CitaviProjectIdentity.objects.filter(global_identity=global_identity, preferred=True).all()[0]
|
||||||
|
|
|
@ -46,3 +46,12 @@ class PersonMapper():
|
||||||
def get_person_by_uuid(self, project, uuid):
|
def get_person_by_uuid(self, project, uuid):
|
||||||
""" Returns a person from a citavi project by uuid. """
|
""" Returns a person from a citavi project by uuid. """
|
||||||
return self._citavi_project_manager.get_person_by_uuid(project.id, uuid)
|
return self._citavi_project_manager.get_person_by_uuid(project.id, uuid)
|
||||||
|
|
||||||
|
def get_representation_for_global_identity(self, global_identity):
|
||||||
|
""" Returns a unicode string representation for a global identiy. """
|
||||||
|
if global_identity.type == 'citavi':
|
||||||
|
citavi_identity = self._person_identity_manager.get_citavi_identity_by_global_identity(global_identity)
|
||||||
|
citavi_person = self._citavi_project_manager.get_person_by_uuid(citavi_identity.project_id, citavi_identity.citavi_uuid)
|
||||||
|
return unicode(citavi_person.ID) + u" " + unicode(citavi_person.FirstName) + u" " + unicode(citavi_person.LastName)
|
||||||
|
else:
|
||||||
|
return unicode(global_identity)
|
Loading…
Reference in New Issue