equal
deleted
inserted
replaced
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
22 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
22 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
23 '"Pawel Solyga" <pawel.solyga@gmail.com>', |
23 '"Pawel Solyga" <pawel.solyga@gmail.com>', |
24 ] |
24 ] |
25 |
25 |
|
26 from google.appengine.ext import db |
26 |
27 |
27 from django import http |
28 from django import http |
28 from django.utils import simplejson |
29 from django.utils import simplejson |
29 from django.utils.translation import ugettext |
30 from django.utils.translation import ugettext |
30 |
31 |
586 request: the django request object |
587 request: the django request object |
587 entity: the entity to create or update from POST contents |
588 entity: the entity to create or update from POST contents |
588 fields: the new field values |
589 fields: the new field values |
589 """ |
590 """ |
590 |
591 |
|
592 scope_path = self._logic.getKeyNameFromFields(fields) |
|
593 |
|
594 key_fields = { |
|
595 'scope_path': scope_path, |
|
596 'prefix': self._params['document_prefix'], |
|
597 } |
|
598 |
|
599 for field_name, original_name, logic, _ in self._params['references']: |
|
600 if field_name not in fields: |
|
601 continue |
|
602 |
|
603 key_fields['link_id'] = fields[field_name] |
|
604 |
|
605 # TODO notify the user if home_doc is not found |
|
606 entity = logic.getFromKeyFields(key_fields) |
|
607 fields[original_name] = entity |
|
608 |
591 # If scope_logic is not defined, this entity has no scope |
609 # If scope_logic is not defined, this entity has no scope |
592 if not self._params['scope_logic']: |
610 if not self._params['scope_logic']: |
593 return |
611 return |
594 |
612 |
595 # If this entity is unscoped, do not try to retrieve a scope |
613 # If this entity is unscoped, do not try to retrieve a scope |
631 |
649 |
632 # fill in the email field with the data from the entity |
650 # fill in the email field with the data from the entity |
633 if 'scope_path' in form.fields: |
651 if 'scope_path' in form.fields: |
634 form.fields['scope_path'].initial = entity.scope_path |
652 form.fields['scope_path'].initial = entity.scope_path |
635 |
653 |
|
654 for field_name, original_name, _, getter in self._params['references']: |
|
655 try: |
|
656 field = getter(entity) |
|
657 form.fields[field_name].initial = field.link_id if field else None |
|
658 except db.Error: |
|
659 pass |
|
660 |
636 field = request.GET.get('field', None) |
661 field = request.GET.get('field', None) |
637 value = request.GET.get('value', None) |
662 value = request.GET.get('value', None) |
638 |
663 |
639 if field and value and field in form.fields: |
664 if field and value and field in form.fields: |
640 form.fields[field].initial = value |
665 form.fields[field].initial = value |
641 |
|
642 |
666 |
643 def _editSeed(self, request, seed): |
667 def _editSeed(self, request, seed): |
644 """Performs any required processing on the form to get its edit page. |
668 """Performs any required processing on the form to get its edit page. |
645 |
669 |
646 Args: |
670 Args: |