[TASK] Show more details for mapped identities.

This commit is contained in:
JPT committed 2014-09-29 16:51:50 +02:00
1 parent 13058a41f7
commit fe3d26f905
8 files changed
+54 -22

No files matched your search

+2 -1
View File
@@ -61,10 +61,11 @@ class PersonMapForm(forms.Form):
self.helper.layout = Layout(
u'action',
u'global_identity',
u'preferred_identity',
Submit(u'skip', u'Skip', css_class=u'btn-default'),
Submit(u'save-continue', u'Save and continue', css_class=u'btn-default'),
)
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)
preferred_identity = forms.BooleanField(initial=False, required=False)
+4 -4
View File
@@ -25,14 +25,14 @@ class PersonGlobalIdentity(models.Model):
def __unicode__(self):
from service.Mapper import PersonMapper
pm = PersonMapper()
return u"<PersonGlobalIdentity repr=" + pm.get_representation_for_global_identity(self) + u" ID=" + unicode(self.id) + u", type=" + unicode(self.type) + u">"
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):
""" Model representing an identity from a citavi project. """
global_identity = models.ForeignKey(PersonGlobalIdentity, blank=True, null=True)
project = models.ForeignKey(Project, blank=False, null=False)
citavi_uuid = models.CharField(max_length=255, blank=False, null=False)
global_identity = models.ForeignKey(PersonGlobalIdentity, blank=True, null=True, db_index=True)
project = models.ForeignKey(Project, blank=False, null=False, db_index=True)
citavi_uuid = models.CharField(max_length=255, blank=False, null=False, db_index=True)
preferred = models.BooleanField()
def __unicode__(self):
+5 -3
View File
@@ -65,15 +65,17 @@
<thead>
<tr>
<th>Citavi_UUID</th>
<th>Features</th>
<th>Name</th>
<th>Global Identity</th>
<th>Features</th>
</tr>
</thead>
<tbody>
{% for person_id, person in mapped_persons.items %}
<tr>
<td>{{person.citavi_uuid}}</td>
<td>{{person.global_identity}}</td>
<td>{{person.0.citavi_uuid}}</td>
<td>{{person.1}}</td>
<td>{{person.0.global_identity}}</td>
<td>
<a href="#TODO" title="Enter mapping wizard starting here.">Delete Mapping</a>
</td>
+12 -7
View File
@@ -190,7 +190,8 @@ class ProjectPersonView(ProtectedFormView, SingleObjectMixin):
from service import Mapper
pm = Mapper.PersonMapper()
kwargs[u'unmapped_persons'] = pm.get_unmapped_identities(project)
kwargs[u'mapped_persons'] = pm.get_mapped_identities(project)
kwargs[u'mapped_persons'] = pm.get_mapped_identities_with_representation(project)
kwargs[u'mapped_persons'] = pm.get_mapped_identities_with_representation(project)
return super(ProjectPersonView, self).get_context_data(**kwargs)
def get(self, request, *args, **kwargs):
@@ -240,12 +241,16 @@ class ProjectMapPersonView(ProtectedFormView, SingleObjectMixin):
pm = Mapper.PersonMapper()
person = pm.get_person_by_uuid(self.object, self.person_uuid)
print unicode(form.cleaned_data)
# TODO: do mapping according to parameters, override success_url to point to next person!
if form.cleaned_data[u'action'] == u'new':
pm.create_new_identity(self.object, person)
elif form.cleaned_data[u'action'] == u'skip':
if form.data.get(u'skip', False):
""" Nothing to do here, just go on ... """
pass
elif form.data.get(u'save-continue', False):
# TODO: do mapping according to parameters, override success_url to point to next person!
if form.cleaned_data[u'action'] == u'new':
pm.create_new_identity(self.object, person)
elif form.cleaned_data[u'action'] == u'existing':
# TODO preferred = FALSE is not desired.
print form.cleaned_data
pm.map_identity_to_existing(form.cleaned_data[u'global_identity'], self.object, person.ID, form.cleaned_data[u'preferred_identity'])
return super(ProjectMapPersonView, self).form_valid(form)