def get(self): # Check the request parameters. if not self.params.id: return self.error(404, 'No person id was specified.') try: person = Person.get_by_person_record_id(self.params.id) except ValueError: return self.error(404, 'There is no record for the specified id.') if not person: return self.error(404, 'There is no record for the specified id.') standalone = self.request.get('standalone') # Check if private info should be revealed. content_id = 'view:' + self.params.id reveal_url = reveal.make_reveal_url(self.request.url, content_id) show_private_info = reveal.verify(content_id, self.params.signature) # Get the notes and duplicate links. notes = Note.get_by_person_record_id(person.person_record_id, limit=200) person.sex_text = get_person_sex_text(person) for note in notes: note.status_text = get_note_status_text(note) linked_persons = person.get_linked_persons(note_limit=200) linked_person_info = [dict(id = p.person_record_id, name = "%s %s" % (p.first_name, p.last_name)) for p in linked_persons] # Render the page. self.render('templates/view.html', params=self.params, linked_person_info=linked_person_info, person=person, notes=notes, standalone=standalone, onload_function='view_page_loaded()', reveal_url=reveal_url, show_private_info=show_private_info)
def get(self): # To handle multiple persons, we create a single object where # each property is a list of values, one for each person. # This makes page rendering easier. person = dict([(prop, []) for prop in COMPARE_FIELDS]) any_person = dict([(prop, None) for prop in COMPARE_FIELDS]) # Get all persons from db. # TODO: Can later optimize to use fewer DB calls. for i in [1, 2, 3]: id = self.request.get('id%d' % i) if not id: break p = Person.get(self.repo, id) if not p: return self.error( 404, _("This person's entry does not exist or has been " "deleted.")) sanitize_urls(p) for prop in COMPARE_FIELDS: val = getattr(p, prop) if prop == 'sex': # convert enum value to localized text val = get_person_sex_text(p) elif prop == 'photo_url' and val: val = (self.should_show_inline_photo(val), val) person[prop].append(val) any_person[prop] = any_person[prop] or val # Compute the local times for the date fields on the person and format. person['source_datetime_local_string'] = map( self.to_formatted_local_datetime, person['source_date']) # Check if private info should be revealed. content_id = 'multiview:' + ','.join(person['person_record_id']) reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) # TODO: Handle no persons found. person['profile_pages'] = [ view.get_profile_pages(profile_urls, self) for profile_urls in person['profile_urls'] ] any_person['profile_pages'] = any(person['profile_pages']) # Note: we're not showing notes and linked persons information # here at the moment. self.render('multiview.html', person=person, any=any_person, cols=len(person['full_name']) + 1, onload_function='view_page_loaded', markdup=True, show_private_info=show_private_info, reveal_url=reveal_url)
def get(self): # To handle multiple persons, we create a single object where # each property is a list of values, one for each person. # This makes page rendering easier. person = dict([(prop, []) for prop in COMPARE_FIELDS]) any_person = dict([(prop, None) for prop in COMPARE_FIELDS]) # Get all persons from db. # TODO: Can later optimize to use fewer DB calls. for i in [1, 2, 3]: id = self.request.get('id%d' % i) if not id: break p = Person.get(self.repo, id) if not p: return self.error( 404, _("This person's entry does not exist or has been " "deleted.")) sanitize_urls(p) for prop in COMPARE_FIELDS: val = getattr(p, prop) if prop == 'sex': # convert enum value to localized text val = get_person_sex_text(p) person[prop].append(val) any_person[prop] = any_person[prop] or val # Compute the local times for the date fields on the person and format. person['source_datetime_local_string'] = map( self.to_formatted_local_datetime, person['source_date']) # Check if private info should be revealed. content_id = 'multiview:' + ','.join(person['person_record_id']) reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) # TODO: Handle no persons found. person['profile_pages'] = [view.get_profile_pages(profile_urls, self) for profile_urls in person['profile_urls']] any_person['profile_pages'] = any(person['profile_pages']) # Note: we're not showing notes and linked persons information # here at the moment. self.render('multiview.html', person=person, any=any_person, cols=len(person['full_name']) + 1, onload_function='view_page_loaded', markdup=True, show_private_info=show_private_info, reveal_url=reveal_url)
def get(self): note = model.Note.get(self.subdomain, self.params.id) if not note: return self.error(400, 'No note with ID: %r' % self.params.id) note.status_text = utils.get_note_status_text(note) captcha_html = note.hidden and self.get_captcha_html() or '' # Check if private info should be revealed. content_id = 'view:' + note.person_record_id reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) self.render('templates/flag_note.html', onload_function='load_language_api()', note=note, captcha_html=captcha_html, reveal_url=reveal_url, flag_note_page=True, show_private_info=show_private_info, signature=self.params.signature)
def get(self): # To handle multiple persons, we create a single object where # each property is a list of values, one for each person. # This makes page rendering easier. person = dict([(prop, []) for prop in COMPARE_FIELDS]) any = dict([(prop, None) for prop in COMPARE_FIELDS]) # Get all persons from db. # TODO: Can later optimize to use fewer DB calls. for i in [1, 2, 3]: id = self.request.get('id%d' % i) if not id: break p = Person.get(self.subdomain, id) for prop in COMPARE_FIELDS: val = getattr(p, prop) if prop == 'sex': # convert enum value to localized text val = get_person_sex_text(p) person[prop].append(val) any[prop] = any[prop] or val # Check if private info should be revealed. content_id = 'multiview:' + ','.join(person['person_record_id']) reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) # TODO: Handle no persons found. # Add a calculated full name property - used in the title. person['full_name'] = [ fname + ' ' + lname for fname, lname in zip(person['first_name'], person['last_name'])] standalone = self.request.get('standalone') # Note: we're not showing notes and linked persons information # here at the moment. self.render('templates/multiview.html', person=person, any=any, standalone=standalone, cols=len(person['first_name']) + 1, onload_function='view_page_loaded()', markdup=True, show_private_info=show_private_info, reveal_url=reveal_url)
def get(self): note = model.Note.get(self.repo, self.params.id) if not note: return self.error(400, 'No note with ID: %r' % self.params.id) note.status_text = utils.get_note_status_text(note) note.source_date_local = self.to_local_time(note.source_date) captcha_html = note.hidden and self.get_captcha_html() or '' # Check if private info should be revealed. content_id = 'view:' + note.person_record_id reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) self.render('flag_note.html', note=note, captcha_html=captcha_html, reveal_url=reveal_url, flag_note_page=True, show_private_info=show_private_info, signature=self.params.signature)
def get(self): # Check the request parameters. if not self.params.id: return self.error(404, 'No person id was specified.') try: person = Person.get(self.repo, self.params.id) except ValueError: return self.error(404, _("This person's entry does not exist or has been deleted.")) if not person: return self.error(404, _("This person's entry does not exist or has been deleted.")) standalone = self.request.get('standalone') # Check if private info should be revealed. content_id = 'view:' + self.params.id reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) # Compute the local times for the date fields on the person. person.source_date_local_string = self.to_formatted_local_date( person.source_date) person.source_time_local_string = self.to_formatted_local_time( person.source_date) person.expiry_date_local_string = self.to_formatted_local_date( person.get_effective_expiry_date()) person.expiry_time_local_string = self.to_formatted_local_time( person.get_effective_expiry_date()) person.should_show_inline_photo = ( self.should_show_inline_photo(person.photo_url)) # Get the notes and duplicate links. try: notes = person.get_notes() except datastore_errors.NeedIndexError: notes = [] person.sex_text = get_person_sex_text(person) for note in notes: self.__add_fields_to_note(note) try: linked_persons = person.get_all_linked_persons() except datastore_errors.NeedIndexError: linked_persons = [] linked_person_info = [] for linked_person in linked_persons: try: linked_notes = linked_person.get_notes() except datastore_errors.NeedIndexError: linked_notes = [] for note in linked_notes: self.__add_fields_to_note(note) linked_person_info.append(dict( id=linked_person.record_id, name=linked_person.primary_full_name, view_url=self.get_url('/view', id=linked_person.record_id), notes=linked_notes)) # Render the page. dupe_notes_url = self.get_url( '/view', id=self.params.id, dupe_notes='yes') results_url = self.get_url( '/results', role=self.params.role, query_name=self.params.query_name, query_location=self.params.query_location, given_name=self.params.given_name, family_name=self.params.family_name) feed_url = self.get_url( '/feeds/note', person_record_id=self.params.id, repo=self.repo) subscribe_url = self.get_url('/subscribe', id=self.params.id) delete_url = self.get_url('/delete', id=self.params.id) disable_notes_url = self.get_url('/disable_notes', id=self.params.id) enable_notes_url = self.get_url('/enable_notes', id=self.params.id) extend_url = None extension_days = 0 expiration_days = None expiry_date = person.get_effective_expiry_date() if expiry_date and not person.is_clone(): expiration_delta = expiry_date - get_utcnow() extend_url = self.get_url('/extend', id=self.params.id) extension_days = extend.get_extension_days(self) if expiration_delta.days < EXPIRY_WARNING_THRESHOLD: # round 0 up to 1, to make the msg read better. expiration_days = expiration_delta.days + 1 if person.is_clone(): person.provider_name = person.get_original_domain() sanitize_urls(person) for note in notes: sanitize_urls(note) if person.profile_urls: person.profile_pages = get_profile_pages(person.profile_urls, self) self.render('view.html', person=person, notes=notes, linked_person_info=linked_person_info, standalone=standalone, onload_function='view_page_loaded()', show_private_info=show_private_info, admin=users.is_current_user_admin(), dupe_notes_url=dupe_notes_url, results_url=results_url, reveal_url=reveal_url, feed_url=feed_url, subscribe_url=subscribe_url, delete_url=delete_url, disable_notes_url=disable_notes_url, enable_notes_url=enable_notes_url, extend_url=extend_url, extension_days=extension_days, expiration_days=expiration_days)
def get(self): # Check the request parameters. if not self.params.id: return self.error(404, 'No person id was specified.') try: person = Person.get(self.repo, self.params.id) except ValueError: return self.error(404, _("This person's entry does not exist or has been deleted.")) if not person: return self.error(404, _("This person's entry does not exist or has been deleted.")) standalone = self.request.get('standalone') # Check if private info should be revealed. content_id = 'view:' + self.params.id reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) # Compute the local times for the date fields on the person. person.source_date_local_string = self.to_formatted_local_time( person.source_date) person.expiry_date_local_string = self.to_formatted_local_time( person.get_effective_expiry_date()) person.should_show_inline_photo = ( self.should_show_inline_photo(person.photo_url)) # Get the notes and duplicate links. try: notes = person.get_notes() except datastore_errors.NeedIndexError: notes = [] person.sex_text = get_person_sex_text(person) for note in notes: self.__add_fields_to_note(note) try: linked_persons = person.get_all_linked_persons() except datastore_errors.NeedIndexError: linked_persons = [] linked_person_info = [] for linked_person in linked_persons: try: linked_notes = linked_person.get_notes() except datastore_errors.NeedIndexError: linked_notes = [] for note in linked_notes: self.__add_fields_to_note(note) linked_person_info.append(dict( id=linked_person.record_id, name=linked_person.primary_full_name, view_url=self.get_url('/view', id=linked_person.record_id), notes=linked_notes)) # Render the page. dupe_notes_url = self.get_url( '/view', id=self.params.id, dupe_notes='yes') results_url = self.get_url( '/results', role=self.params.role, query=self.params.query, given_name=self.params.given_name, family_name=self.params.family_name) feed_url = self.get_url( '/feeds/note', person_record_id=self.params.id, repo=self.repo) subscribe_url = self.get_url('/subscribe', id=self.params.id) delete_url = self.get_url('/delete', id=self.params.id) disable_notes_url = self.get_url('/disable_notes', id=self.params.id) enable_notes_url = self.get_url('/enable_notes', id=self.params.id) extend_url = None extension_days = 0 expiration_days = None expiry_date = person.get_effective_expiry_date() if expiry_date and not person.is_clone(): expiration_delta = expiry_date - get_utcnow() extend_url = self.get_url('/extend', id=self.params.id) extension_days = extend.get_extension_days(self) if expiration_delta.days < EXPIRY_WARNING_THRESHOLD: # round 0 up to 1, to make the msg read better. expiration_days = expiration_delta.days + 1 if person.is_clone(): person.provider_name = person.get_original_domain() sanitize_urls(person) for note in notes: sanitize_urls(note) if person.profile_urls: person.profile_pages = get_profile_pages(person.profile_urls, self) self.render('view.html', person=person, notes=notes, linked_person_info=linked_person_info, standalone=standalone, onload_function='view_page_loaded()', show_private_info=show_private_info, admin=users.is_current_user_admin(), dupe_notes_url=dupe_notes_url, results_url=results_url, reveal_url=reveal_url, feed_url=feed_url, subscribe_url=subscribe_url, delete_url=delete_url, disable_notes_url=disable_notes_url, enable_notes_url=enable_notes_url, extend_url=extend_url, extension_days=extension_days, expiration_days=expiration_days)
def get(self): # Check the request parameters. if not self.params.id: return self.error(404, 'No person id was specified.') try: person = Person.get(self.subdomain, self.params.id) except ValueError: return self.error(404, 'There is no record for the specified id.') if not person: return self.error(404, 'There is no record for the specified id.') standalone = self.request.get('standalone') # Check if private info should be revealed. content_id = 'view:' + self.params.id reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) # Get the notes and duplicate links. try: notes = person.get_notes() except datastore_errors.NeedIndexError: notes = [] person.sex_text = get_person_sex_text(person) for note in notes: note.status_text = get_note_status_text(note) note.linked_person_url = \ self.get_url('/view', id=note.linked_person_record_id) note.flag_spam_url = \ self.get_url('/flag_note', id=note.note_record_id, hide=(not note.hidden) and 'yes' or 'no', signature=self.params.signature) try: linked_persons = person.get_linked_persons() except datastore_errors.NeedIndexError: linked_persons = [] linked_person_info = [ dict(id=p.record_id, name="%s %s" % (p.first_name, p.last_name), view_url=self.get_url('/view', id=p.record_id)) for p in linked_persons ] # Render the page. dupe_notes_url = self.get_url('/view', id=self.params.id, dupe_notes='yes') results_url = self.get_url('/results', role=self.params.role, query=self.params.query, first_name=self.params.first_name, last_name=self.params.last_name) feed_url = self.get_url('/feeds/note', person_record_id=self.params.id, subdomain=self.subdomain) subscribe_url = self.get_url('/subscribe', id=self.params.id) self.render('templates/view.html', person=person, notes=notes, linked_person_info=linked_person_info, standalone=standalone, onload_function='view_page_loaded()', show_private_info=show_private_info, admin=users.is_current_user_admin(), dupe_notes_url=dupe_notes_url, results_url=results_url, reveal_url=reveal_url, feed_url=feed_url, subscribe_url=subscribe_url)
def get(self): # Check the request parameters. if not self.params.id: return self.error(404, 'No person id was specified.') try: person = Person.get(self.subdomain, self.params.id) except ValueError: return self.error(404, 'There is no record for the specified id.') if not person: return self.error(404, 'There is no record for the specified id.') standalone = self.request.get('standalone') # Check if private info should be revealed. content_id = 'view:' + self.params.id reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) # Get the notes and duplicate links. try: notes = person.get_notes() except datastore_errors.NeedIndexError: notes = [] person.sex_text = get_person_sex_text(person) for note in notes: note.status_text = get_note_status_text(note) note.linked_person_url = \ self.get_url('/view', id=note.linked_person_record_id) note.flag_spam_url = \ self.get_url('/flag_note', id=note.note_record_id, hide=(not note.hidden) and 'yes' or 'no', signature=self.params.signature) try: linked_persons = person.get_linked_persons() except datastore_errors.NeedIndexError: linked_persons = [] linked_person_info = [ dict(id=p.record_id, name="%s %s" % (p.first_name, p.last_name), view_url=self.get_url('/view', id=p.record_id)) for p in linked_persons] # Render the page. dupe_notes_url = self.get_url( '/view', id=self.params.id, dupe_notes='yes') results_url = self.get_url( '/results', role=self.params.role, query=self.params.query, first_name=self.params.first_name, last_name=self.params.last_name) feed_url = self.get_url( '/feeds/note', person_record_id=self.params.id, subdomain=self.subdomain) subscribe_url = self.get_url('/subscribe', id=self.params.id) self.render('templates/view.html', person=person, notes=notes, linked_person_info=linked_person_info, standalone=standalone, onload_function='view_page_loaded()', show_private_info=show_private_info, admin=users.is_current_user_admin(), dupe_notes_url=dupe_notes_url, results_url=results_url, reveal_url=reveal_url, feed_url=feed_url, subscribe_url=subscribe_url)
def get(self): # Check the request parameters. if not self.params.id: return self.error(404, "No person id was specified.") try: person = Person.get(self.subdomain, self.params.id) except ValueError: return self.error(404, "There is no record for the specified id.") if not person: return self.error(404, "There is no record for the specified id.") standalone = self.request.get("standalone") # Check if private info should be revealed. content_id = "view:" + self.params.id reveal_url = reveal.make_reveal_url(self, content_id) show_private_info = reveal.verify(content_id, self.params.signature) # Get the notes and duplicate links. try: notes = person.get_notes() except datastore_errors.NeedIndexError: notes = [] person.sex_text = get_person_sex_text(person) for note in notes: note.status_text = get_note_status_text(note) note.linked_person_url = self.get_url("/view", id=note.linked_person_record_id) try: linked_persons = person.get_linked_persons(note_limit=200) except datastore_errors.NeedIndexError: linked_persons = [] linked_person_info = [ dict( id=p.record_id, name="%s %s" % (p.first_name, p.last_name), view_url=self.get_url("/view", id=p.record_id), ) for p in linked_persons ] # Render the page. dupe_notes_url = self.get_url("/view", id=self.params.id, dupe_notes="yes") results_url = self.get_url( "/results", role=self.params.role, query=self.params.query, first_name=self.params.first_name, last_name=self.params.last_name, ) self.render( "templates/view.html", params=self.params, linked_person_info=linked_person_info, person=person, notes=notes, standalone=standalone, onload_function="view_page_loaded()", reveal_url=reveal_url, show_private_info=show_private_info, noindex=True, admin=users.is_current_user_admin(), dupe_notes_url=dupe_notes_url, results_url=results_url, )