Database Part Modules¶
hedwig.db.part.calculator¶
- class hedwig.db.part.calculator.CalculatorPart¶
- add_calculation(proposal_id, calculator_id, mode, version, input_, output, calc_version, title)¶
- _add_calculation(table, key_column, key_value, calculator_id, mode, version, input_, output, calc_version, title)¶
- add_moc(facility_id, name, description, description_format, public, moc_object)¶
- add_review_calculation(reviewer_id, calculator_id, mode, version, input_, output, calc_version, title)¶
- delete_moc(facility_id, moc_id)¶
Delete a MOC from the database.
- ensure_calculator(facility_id, code, _read_only=False)¶
Ensure that a calculator exists in the database.
If the calculator exists, its identifier is returned. Otherwise it is added and the new identifier is returned.
- get_calculation(id_)¶
- get_moc_fits(moc_id)¶
- get_review_calculation(id_)¶
- search_calculation(calculation_id=None, proposal_id=None)¶
- _search_calculation(table, key_column, key_value, id_, result_class)¶
- search_moc(facility_id, public, moc_id=None, state=None, with_description=False, order_by_date=False)¶
Search for MOC records for a facility.
- search_moc_cell(facility_id, public, order, cell)¶
Search for a MOC containing the given cell, or a cell at a lower order containing this cell.
Multiple cells can be specified to allow a certain region to be searched. The number of cells given should be reasonable since this function assembles a single SQL query for all cells at all levels being searched.
- _search_moc_cell_query(order, cell)¶
Generate list of orders and cells to use in a MOC cell search.
- search_review_calculation(review_calculation_id=None, reviewer_id=None)¶
- sync_proposal_calculation(proposal_id, records)¶
Update the calculations for a proposal.
Currently only deleting calculations and updating the sort order is supported.
- sync_review_calculation(reviewer_id, records)¶
Update the calculations for a reviewer.
Currently only deleting calculations and updating the sort order is supported.
- update_calculation(calculation_id, mode, version, input_, output, calc_version, title)¶
- _update_calculation(table, id_, mode, version, input_, output, calc_version, title)¶
- update_moc(moc_id, name=None, description=None, description_format=None, public=None, moc_object=None, state=None, state_prev=None, state_is_system=False)¶
- update_moc_cell(moc_id, moc_object, block_size=1000, block_pause=1)¶
Update the moc_cell database table.
The entries for the MOC identified by moc_id are updated so that they match the entries of the MOC provided as moc_object.
This method works in an order-by-order manner and attempts to determine the most efficient update method for each order. If the number of original cells is greater than the number of unchanged cells, then all exising entries are deleted and the new cells inserted. Otherwise removed cells are deleted individually and newly added cells inserted.
For debugging purposes, this method returns a dictionary indicating the action taken for each order.
- _get_moc_from_cell(moc_id, _conn=None)¶
Retrieve a MOC object from the moc_cell database table.
This routine should not generally be used to retrieve a MOC: instead use get_moc_fits, or search the moc using search_moc_cell. This method is intended to be used only to optimize update operations (and for use by the test suite).
- update_review_calculation(review_calculation_id, mode, version, input_, output, calc_version, title)¶
hedwig.db.part.message¶
- class hedwig.db.part.message.MessagePart¶
- add_message(subject, body, person_ids, email_addresses=[], thread_type=None, thread_id=None, format_type=2, _test_skip_check=False)¶
Add a message to the database.
“email_addresses” can normally be left empty, but if it is necessary to send to a particular address (rather than the person’s primary address) then it can be a list with email addresses in the same order as the person_ids list.
- get_message(message_id)¶
Retrieve a message from the database.
- search_message(person_id=None, state=None, message_id=None, message_id_lt=None, thread_type=None, thread_id=None, limit=None, oldest_first=False, with_body=False, with_thread_identifiers=False, with_recipients=False, with_recipients_resolved=False, _conn=None)¶
Searches for messages.
The selection of messages to be returned can be controlled with the optional keyword arguments.
- search_message_recipient(message_id=None, with_resolved_email=False, _conn=None)¶
Search for message recipient records.
- update_message(message_id, state=None, state_prev=None, state_is_system=False, timestamp_send=(), timestamp_sent=(), identifier=None, _conn=None, _test_skip_check=False)¶
Update a message record.
hedwig.db.part.people¶
- class hedwig.db.part.people.PeoplePart¶
- add_email(person_id, address, primary=False, verified=False, public=False, _conn=None, _test_skip_check=False)¶
Add an email address record to the databae.
Returns the email_id number.
- add_institution(name, department, organization, address, country, name_abbr=None, department_abbr=None, organization_abbr=None, adder_person_id=None)¶
Add an institution to the database.
Returns the new institution_id number.
- add_person(name, title=None, public=False, user_id=None, remote_addr=None, primary_email=None, institution_id=None, _test_skip_check=False)¶
Add a person to the database.
If the user_id for an existing user is provided, then the person includes a reference to that user.
If a primary_email address is given, it is added as the person’s primary email address.
- add_person_log_entry(person_id, event, proposal_id=None, institution_id=None, other_person_id=None, _conn=None)¶
Adds an entry to the person log table.
- add_oauth_code(code, redirect_uri, response_type, nonce, client_id, scope, person_id)¶
- add_oauth_token(token_type, access_token, refresh_token, client_id, scope, person_id, expires_in)¶
- add_site_group_member(site_group_type, person_id, _conn=None, _test_skip_check=False)¶
- add_user(name, password_raw, person_id=None, remote_addr=None, _test_skip_check=False)¶
Add a user to the database.
The given raw password is used to generate a salted password hash which is then stored in the database. If a person_id for an existing person is given, then that person’s record is updated to contain a reference to this user.
- authenticate_user(name, password_raw, user_id=None, remote_addr=None)¶
Given a user name and raw password, try to authenitcate the user.
Can take a user_id instead of a user name for re-authentication, e.g. before changing password. In that case, name must be explicitly set to None (to prevent accidental use of this rare use-case).
Returns the user_id on success, None otherwise.
Attempts to protect against multiple authentication attempts, but only if “name” is given. (I.e. not in user_id re-authentication mode.)
- _record_auth_failure(name)¶
Record an authentication failure.
- _delete_auth_failure(user_name, _conn=None)¶
Delete authentication failure records for a given user name.
This can be used, for example, after a user has reset their password via the password reset system.
- authenticate_token(token)¶
If the given token is valid, return the corresponding user.
Expired token are automatically deleted before the search is performed. Additionally if more that 10 minutes of the token’s duration has elapsed, its expiry date is refreshed.
- Returns:
a (UserInfo, auth_token_id) tuple
- _delete_auth_expired(conn)¶
- delete_auth_token(token=None, user_id=None, auth_token_id=None, auth_token_id_not=None)¶
- delete_institution(institution_id, _test_skip_check=False)¶
Attempt to delete an institution.
Note that the database constraints may prevent this method from succeeding, for example if a person has this institution selected in their profile or “frozen” into their membership of a proposal.
- delete_user(user_id, _test_skip_check=False)¶
Delete a user record.
The user can not be registered, i.e. there can not be a person record with this user_id.
- delete_oauth_code(code_id)¶
Delete the given authorization code.
- _delete_oauth_expired(conn)¶
Delete expired OAuth data.
This removes authorization codes and, since refresh is not implemented, access tokens.
- get_institution(institution_id, _conn=None)¶
Get an institution record.
- get_invitation_person(token, *args, **kwargs)¶
Get the person record associated with an invitation.
Any additional “args” and “kwargs” are passed to the “get_person” method.
NoSuchRecord is raised if the token does not exist and RecordExpired is raised if it does exist but has expired.
Simply returns the Person record from “get_person” since there is no other useful information associated with an invitation.
- get_person(person_id, user_id=None, with_email=False, with_institution=False, with_proposals=False, with_reviews=False, _conn=None)¶
Get a person record.
Can take a user_id instead of a person_id, but in that case, person_id must be explicitly set to None (to prevent accidental use of this rare use-case).
Raises NoSuchRecord if the person_id doesn’t exist.
- get_user_id(user_name)¶
Get the user_id for the given user name.
- get_user_name(user_id, _conn=None)¶
Get the user name associated with the given user_id.
- issue_auth_token(user_id, remote_addr, remote_agent)¶
Create a user authentication token.
- issue_email_verify_token(person_id, email_address, user_id, remote_addr=None)¶
Create a email address verification token.
Stores the person_id along with the generated token in the database so that we can ensure only one token is issued per person and address.
- issue_invitation(person_id, days_valid=30, _test_skip_check=False)¶
Creates an invitation token to allow someone to register as the given person and adds it to the database.
Deletes existing tokens to register as this person.
Returns a tuple of the new token and its expiry.
- issue_password_reset_token(user_id, remote_addr, _test_skip_check=False)¶
Create a password reset token for a given user.
Deletes any existing tokens for this user and returns a tuple of the new token and its expiry date.
- merge_institution_records(main_institution_id, duplicate_institution_id, _test_skip_check=False)¶
Merge the two given institutions.
Deletes all log entries corresponding to the duplicate and then changes references to the duplicate to point at the main record before deleting it.
- merge_person_records(main_person_id, duplicate_person_id, duplicate_person_registered=None, _user_log_event=8, _user_log_remote_addr=None, _conn=None, _test_skip_check=False)¶
Merge the two given person records.
- search_auth_token()¶
Find authentication token records.
- search_email(person_id, address=None, _conn=None)¶
Find email address records.
- search_institution(institution_id=None, has_registered_person=None)¶
Search institution records.
Summary information is returned.
- search_institution_log(institution_id=None, approved=None, has_unapproved=None)¶
Search for records in the institution edit log.
Note that the web interface (hedwig.view.people._display_institution_log) needs the values in descending order as it works backwards from the current version of each institution record.
Note also that if you want to see the history of edits to an institution, you should probably not filter by the “approved” status. Instead use the “has_unapproved” argument to select only those institutions which have unapproved changes and filter out already approved changes for display. This will allow you to see the ‘before’ and ‘after’ of each change since the log only stores the ‘before’ – you need to next log entry, or current record, to get the ‘after’ values.
- search_oauth_code(client_id, code=None, nonce=None)¶
- search_oauth_token(client_id, access_token=None)¶
- search_person(person_id=None, user_id=None, email_address=None, registered=None, public=None, admin=None, institution_id=None, with_institution=False)¶
Find person records.
- search_person_log(person_id, **kwargs)¶
Search for person log entries.
- search_site_group_member(site_group_type=None, person_id=None, site_group_member_id=None, with_person=False, _conn=None)¶
- search_user(registered=None, user_id=None)¶
Search for user accounts.
- search_user_log(user_id, **kwargs)¶
Search for user log entries.
- _search_event_log(table, result_class, result_collection_class, user_id=None, person_id=None, event=None, date_after=None, _conn=None)¶
- sync_institution_log_approval(records)¶
Update the approval status for some institution edit log entries.
Takes a dictionary of log entry identifiers where the values are booleans indicating whether the entry is approved or not.
This method works in terms of log entries rather than individual institutions so that it could be used for log entries for multiple institutions.
- sync_person_email(person_id, records)¶
Update the email records for a person to match those given in “records”.
The “verified” column is not updated.
- sync_site_group_member(site_group_type, records)¶
Update the member records of the given site group.
Currently this just allows removing members of the group, but could be extended if group members gain extra attributes.
- update_institution(institution_id, updater_person_id=None, name=None, department=None, organization=None, address=None, country=None, name_abbr=(), department_abbr=(), organization_abbr=(), log_approved=False, _test_skip_log=False)¶
Update an institution record.
- update_person(person_id, name=None, title=(), public=None, institution_id=(), admin=None, verified=None, _conn=None, _test_skip_check=False)¶
Update a person database record.
- update_user(user_id, disabled=None, _test_skip_check=False)¶
Update general parameters of a user database record.
- update_user_name(user_id, name, remote_addr=None, _test_skip_check=False)¶
- update_user_password(user_id, password_raw, remote_addr=None, _test_skip_check=False, _skip_log=False, _conn=None)¶
Update a user’s password.
- Raises:
UserError – if the password is blank.
- use_email_verify_token(person_id, token, user_id, remote_addr=None)¶
Tries to use the given email verification token.
Also ensures the person record is marked as verified.
- use_password_reset_token(token, password_raw, remote_addr)¶
Tries to use the given password reset token.
- Returns:
the user_name corresponding to the given token, if successful.
- Raises:
NoSuchRecord – if the token is not found.
- use_invitation(token, user_id=None, new_person_id=None, remote_addr=None, _test_skip_check=False)¶
Uses the invitation token to link the given user_id to the person record associated with the invitation.
Also ensures the person record is marked as verified.
Returns the person record to which the invitation refers as it was before the invitation was accepted.
- _add_user_log_entry(conn, user_id, event, remote_addr=None)¶
Adds an entry to the user log table.
- _check_rate_limit(conn, user_id, event, limit)¶
Checks the number of user log entries for the given event type against the specified limit.
- Raises:
UserError if excess entries present.
- _exists_person_user(conn, user_id)¶
Test whether a person exists with the given user_id.
- _exists_user_name(conn, name)¶
Test whether a user exists by name.
hedwig.db.part.proposal¶
- class hedwig.db.part.proposal.ProposalPart¶
- add_affiliation(type_class, queue_id, name, type_=None)¶
Add an affiliation to the database.
- add_call(type_class, semester_id, queue_id, type_, date_open, date_close, abst_word_lim, tech_word_lim, tech_fig_lim, tech_page_lim, sci_word_lim, sci_fig_lim, sci_page_lim, capt_word_lim, expl_word_lim, tech_note, sci_note, prev_prop_note, note_format, multi_semester, separate, preamble, preamble_format, hidden, allow_continuation, cnrq_note, cnrq_word_lim, cnrq_fig_lim, cnrq_page_lim, cnrq_max_age, _test_skip_check=False)¶
Add a call for proposals to the database.
- add_member(proposal_id, person_id, affiliation_id, pi=False, editor=False, observer=False, reviewer=False, adder_person_id=None, is_invite=False, _conn=None, _test_skip_check=False)¶
- add_proposal(call_id, person_id, affiliation_id, title, type_=1, state=1, person_is_reviewer=False, is_copy=False, _test_skip_check=False)¶
Add a new proposal to the database.
The given person will be added as a member, assumed to be PI and with “editor” permission so that they can continue to prepare the proposal. This person’s affiliation (for the relevant facility) should be given for inclusion in the member table.
- add_proposal_annotation(proposal_id, type_, annotation, _test_skip_check=False, _conn=None)¶
- add_proposal_figure(role_class, proposal_id, role, type_, figure, caption, filename, uploader_person_id, _test_skip_check=False)¶
- _add_figure(table, table_link, key_column, key_value, foreign_table, type_, figure, caption, filename, uploader_person_id, extra={}, _test_skip_check=False)¶
- add_queue(facility_id, name, code, description='', description_format=1, _test_skip_check=False)¶
Add a queue to the database.
- add_request_prop_copy(proposal_id, requester_person_id, call_id, affiliation_id, copy_members, continuation, _test_skip_check=False)¶
- add_request_prop_pdf(proposal_id, requester_person_id, _test_skip_check=False)¶
- _add_request_prop(table, proposal_id, requester_person_id, extra_values=None, _conn=None, _test_skip_check=False)¶
- add_semester(facility_id, name, code, date_start, date_end, description='', description_format=1, _test_skip_check=False)¶
Add a semester to the database.
- delete_member_person(proposal_id, person_id)¶
Remove a member from a proposal, by person identifier.
- delete_proposal_figure(proposal_id, role, id_, _allow_any=False, _conn=None)¶
Delete one (or more) figure(s) associated with a proposal.
- Parameters:
proposal_id – the proposal identifier
role – the role number
id – the figure identifier
_allow_any – if true, allows the id_ parameter to be omitted, and skips the check that one figure was successfully deleted
_conn – database connection object, if a transaction has already been started
- _delete_figure(table, table_link, id_, where_extra=[], _allow_any=False, _conn=None)¶
- delete_proposal_pdf(proposal_id, role, _skip_check=False, _allow_count=(1,), _conn=None)¶
Delete a PDF file associated with a proposal.
- Parameters:
proposal_id – the proposal identifier
role – the role number
_skip_check – if true, do not first check that the PDF exists
_allow_count (tuple) – allowed numbers of PDF files to be deleted
_conn – database connection object, if a transaction has already been started
- delete_proposal_text(proposal_id, role, _skip_check=False, _allow_count=(1,), _conn=None)¶
Delete a piece of text associated with a proposal.
- Parameters:
proposal_id – the proposal identifier
role – the role number
_skip_check – if true, do not first check that the text exists
_allow_count (tuple) – allowed numbers of text blocks to be deleted
_conn – database connection object, if a transaction has already been started
- delete_request_prop_copy(request_id, _test_skip_check=False)¶
- delete_request_prop_pdf(request_id, _test_skip_check=False)¶
- _delete_request(table, request_id, _conn=None, _test_skip_check=False)¶
- ensure_facility(code, _read_only=False)¶
Ensure that a facility exists in the database.
If the facility already exists, just return its identifier.
Otherwise add it and return the new identifier.
- get_call(facility_id, call_id)¶
Get a call record.
- get_call_preamble(semester_id, type_)¶
Get the call preamble for a given semester and call type.
- get_original_proposal_ids(proposals, _conn=None)¶
Determine how to look up associated data for proposals.
For example continuation requests do not have their own target list, so we must fetch the corresponding previous proposal IDs and use these to find the targets.
- Returns:
a set of proposal IDs, containing the IDs of standard proposals or the previous proposal of continuation requests, and a dictionary mapping continuation request IDs to their previous proposals.
- get_proposal(facility_id, proposal_id, with_members=False, with_reviewers=False, with_decision=False, with_decision_note=False, with_categories=False, _conn=None)¶
Get a proposal record.
- get_proposal_figure(proposal_id, role, link_id, fig_id=None, md5sum=None)¶
Get a figure associated with a proposal.
Returned as a ProposalFigure object.
- _get_figure(table, table_link, link_id, fig_id, md5sum, where_extra=[])¶
- get_proposal_figure_preview(proposal_id, role, link_id, fig_id=None, md5sum=None)¶
- get_proposal_figure_thumbnail(proposal_id, role, link_id, fig_id=None, md5sum=None)¶
- _get_figure_alternate(table, table_link, column, link_id, fig_id, md5sum, where_extra=[])¶
- get_proposal_pdf(proposal_id, role, pdf_id=None, md5sum=None, _conn=None)¶
Get the given PDF associated with a proposal.
- get_proposal_pdf_preview(proposal_id, role, page, md5sum=None)¶
Get a preview page from a PDF associated with a proposal.
- get_proposal_text(proposal_id, role, _conn=None)¶
Get the given text associated with a proposal.
- get_semester(facility_id, semester_id, _conn=None)¶
Get a semester record.
- get_queue(facility_id, queue_id, _conn=None)¶
Get a queue record.
- link_proposal_pdf(role_class, proposal_id, role, pdf_id, _conn=None, _test_skip_check=False)¶
Link the given proposal PDF to a proposal.
- Returns:
the link identifier
- link_proposal_text(role_class, proposal_id, role, text_id, _conn=None, _test_skip_check=False)¶
Link the given proposal text to a proposal.
- Returns:
the link identifier
- link_proposal_figure(role_class, proposal_id, role, fig_id, sort_order, caption, _conn=None, _test_skip_check=False)¶
Link the given figure to a proposal.
- Returns:
the link identifier
- _link_proposal_attachment(conn, role_class, table, table_link, key_field, proposal_id, role, key_value, extra_values=None, allow_multiple=False, _test_skip_check=False)¶
- search_affiliation(queue_id=None, hidden=None, type_=None, with_weight_call_id=None, with_weight_separate=False, order_by_id=False)¶
Search for affiliation records.
- search_call(call_id=None, facility_id=None, semester_id=None, semester_code=None, queue_id=None, queue_code=None, type_=None, state=None, has_proposal_state=None, date_close_before=None, separate=None, hidden=None, with_queue_description=False, with_case_notes=False, with_preamble=False, with_proposal_count=False, with_proposal_count_state=None, _conn=None)¶
Search for call records.
- search_call_mid_close(call_id=None, closed=None, date_before=None, _conn=None)¶
Search for intermediate call close dates.
- search_call_preamble(semester_id=None, type_=None, _conn=None)¶
Search for call preamble text records.
- search_category(facility_id, hidden=None, order_by_id=False, _conn=None)¶
Search for categories.
- search_co_member(person_id, editor=None, proposal_state=None, with_institution_id=False, _conn=None)¶
Search for proposal co-membership.
For a given person, search for other people who have proposal membership in common. This returns:
Whether the given person is an editor of the common proposal.
The person identifier for the co-member and optionally their institution.
- search_member(proposal_id=None, person_id=None, editor=None, institution_id=None, with_institution=True, _conn=None)¶
Search for proposal members.
- Parameters:
proposal_id – the proposal identifier(s)
person_id – the person idenfifier
editor – whether or not the member is an editor
institution_id – institution identifier(s) query constraint, applied only to institutions “frozen” into the member record
with_institution – whether to include institution information, via the “frozen” institution if present, otherwise the person
- search_semester(facility_id=None, state=None)¶
- search_prev_proposal(proposal_id, continuation=None, resolved=None, with_publications=True, with_proposal_info=False, _conn=None)¶
Search for the previous proposal associated with a given proposal.
- search_prev_proposal_pub(state=None, type_=None, with_proposal_id=False, order_by_date=False)¶
Search for publications associated with previous proposals.
If requested, include the identifier of the parent proposal. (I.e. return prev_proposal.this_proposal_id, not prev_proposal.proposal_id).
- search_proposal(call_id=None, facility_id=None, proposal_id=None, person_id=None, person_is_editor=None, state=None, type_=None, with_member_pi=False, with_members=False, with_reviewers=False, with_review_info=False, with_review_text=False, with_reviewer_role=None, with_review_state=None, with_reviewer_notified=None, with_reviewer_accepted=(), with_reviewer_thanked=(), with_reviewer_note=False, reviewer_person_id=None, with_categories=False, with_decision=False, with_decision_note=False, decision_accept=None, decision_ready=None, decision_accept_defined=None, proposal_number=None, call_type=None, semester_code=None, queue_code=None, queue_id=None, category=None, _conn=None)¶
Search for proposals.
If “person_id” is specified, then this method searches for proposals with this person as a member, and also sets “member” in the returned “Proposal” object to a “MemberInfo” object summarizing that person’s role. Alternatively if “with_member_pi” is enabled, then the PI’s information is returned as a “MemberPIInfo” object.
Otherwise if “with_members” is set, then the “Proposal” object’s “members” attribute is a “MemberCollection” with information about all the members of the proposal.
If “with_reviewers” is set then the “Proposal” object’s “reviewers” attribute is a “ReviewerCollection” with information about the proposal’s reviewers. The contents of this collection are influenced by the “with_review_info”, “with_review_text”, “with_reviewer_role”, “with_review_state”, “with_reviewer_note” arguments.
However if “reviewer_person_id” is set then the “reviewer” attribute in the results is a “ReviewerInfo” object describing the role of the given person. Since in this mode there may be more than one result per proposal, the keys in the returned result collection are reviewer identifiers rather than proposal identifiers.
- search_proposal_annotation(proposal_id, type_=None, _conn=None)¶
Search for annotations associated with a proposal.
- search_proposal_category(proposal_id, _conn=None)¶
Search for the categories associated with a proposal.
- search_proposal_figure(proposal_id=None, role=None, state=None, link_id=None, fig_id=None, with_caption=False, with_uploader_name=False, with_has_preview=False, order_by_date=False, no_link=False)¶
- _search_figure(table, table_link, result_class, result_collection_class, state, link_id, fig_id, with_caption, with_uploader_name, order_by_date, with_has_preview_table=None, select_extra=[], default_extra={}, where_extra=[])¶
- search_proposal_pdf(proposal_id=None, role=None, state=None, with_uploader_name=False, order_by_date=False, no_link=False)¶
- search_proposal_text(proposal_id=None, role=None, with_text=False, _conn=None)¶
- search_queue(facility_id=None, has_affiliation=None)¶
- search_request_prop_copy(request_id=None, proposal_id=None, state=None, continuation=None, **kwargs)¶
- search_request_prop_pdf(request_id=None, proposal_id=None, state=None, **kwargs)¶
- _search_request_prop(table, result_class, request_id, proposal_id, state, requested_before=None, processed_before=None, with_requester_name=False, where_extra=[], _conn=None)¶
- search_target(proposal_id)¶
Retrieve the targets of a given proposal.
- set_call_preamble(type_class, semester_id, type_, description, description_format, _test_skip_check=False)¶
- set_member_institution(member_id, institution_id, _test_skip_check=False)¶
- set_proposal_figure_preview(fig_id, preview)¶
- set_proposal_figure_thumbnail(fig_id, thumbnail)¶
- _set_figure_alternate(column, fig_id, alternate)¶
- set_proposal_pdf(role_class, proposal_id, role, pdf, pages, filename, uploader_person_id, _test_skip_check=False)¶
Insert or update a given proposal PDF.
- Returns:
a (link_id, pdf_id) tuple
- set_proposal_pdf_preview(pdf_id, pngs)¶
Set the preview images for a PDF file attached to a proposal.
- set_proposal_text(role_class, proposal_id, role, text, format, words, editor_person_id, _test_skip_check=False)¶
Insert or update a given piece of proposal text.
- Returns:
a (link_id, text_id) tuple
- sync_affiliation_weight(type_class, call_id, records)¶
Update the affiliation weighting values and possible hidden and type overrides for a given call.
This takes a set of Affiliation records including weights, where the “id” is actually the “affiliation.id” rather than the “affiliation_weight.id”.
- sync_call_call_mid_close(call_id, records)¶
Update intermediate close records associated with a call.
Note: the sync operation is currently performed without handling of the unique constraint (on date) so circular updates will not succeed.
- sync_facility_category(facility_id, records)¶
Update the categories available for proposal for a facility.
- sync_proposal_category(proposal_id, records, _conn=None)¶
Update the categories associated with a proposal.
- sync_proposal_figure(proposal_id, role, records)¶
Update the figures for a proposal.
Currently only deleting figures and changing the sort order is supported.
- sync_proposal_member(proposal_id, records, editor_person_id)¶
Update the member records for a proposal.
Only the “pi”, “editor” and “observer” flags are updated.
- sync_proposal_member_institution(proposal_id, records)¶
Update the institution of members of a proposal.
- sync_proposal_member_student(proposal_id, records)¶
Update the ‘student’ flag of members of a proposal.
- sync_proposal_prev_proposal(proposal_id, records, retain_resolved=False)¶
Update the prev_proposal records related to a proposal.
- Parameters:
retain_resolved – if true, for newly added records, retain the resolved information (title, author and year). (For existing records being updated, these values are cleared for now.)
- _sync_proposal_prev_proposal_pub(conn, prev_proposal_id, existing, publications, retain_resolved=False)¶
- sync_proposal_target(proposal_id, records)¶
Update the target records for a proposal.
- sync_queue_affiliation(type_class, queue_id, records)¶
Update the affiliation records for a queue to match those given by “records”.
- update_call(call_id, date_open=None, date_close=None, abst_word_lim=None, tech_word_lim=None, tech_fig_lim=None, tech_page_lim=None, sci_word_lim=None, sci_fig_lim=None, sci_page_lim=None, capt_word_lim=None, expl_word_lim=None, tech_note=None, sci_note=None, prev_prop_note=None, note_format=None, multi_semester=None, separate=None, preamble=(), preamble_format=(), hidden=None, allow_continuation=None, cnrq_note=None, cnrq_word_lim=None, cnrq_fig_lim=None, cnrq_page_lim=None, cnrq_max_age=(), _test_skip_check=False)¶
Update a call for proposals record.
- update_call_mid_close(id_, closed=None, _test_skip_check=False)¶
Update a call intermediate close record.
- update_prev_proposal_pub(type_=None, description=None, pp_pub_id=None, state=None, title=(), author=(), year=(), state_prev=None)¶
Update all previous proposal publication records for the given reference.
Can either select records to update by the “pp_pub_id” (prev_proposal_pub.id) or by type and description, in which case all matching entries are updated.
- update_request_prop_copy(request_id, state=None, processed=None, state_prev=None, copy_proposal_id=None, state_is_system=False, _test_skip_check=False)¶
- update_request_prop_pdf(request_id, state=None, processed=None, state_prev=None, state_is_system=False, _test_skip_check=False)¶
- _update_request_prop(table, request_id, state=None, processed=None, state_prev=None, extra_values=None, state_is_system=False, _conn=None, _test_skip_check=False)¶
- update_semester(semester_id, name=None, code=None, date_start=None, date_end=None, description=None, description_format=None, _test_skip_check=False)¶
Update a semester record.
- update_proposal(proposal_id, state=None, title=None, state_prev=None, _test_skip_check=False)¶
Update a proposal record.
- update_proposal_figure(proposal_id, role, link_id, fig_id=None, figure=None, type_=None, filename=None, uploader_person_id=None, state=None, state_prev=None, caption=None, state_is_system=False)¶
Update the record of a figure attached to a proposal.
Can be used to update the figure or the state.
If the figure is updated, then the type, filename and uploader must be specified and the state will be set to NEW – the state must not be specifed explicitly.
- Returns:
the internal figure ID (not link ID) if it changed, for test purposes only
- _update_figure(table, table_link, table_preview, table_thumbnail, link_id, fig_id, figure, type_, filename, uploader_person_id, state, state_prev, caption, where_extra=[], state_is_system=False)¶
- update_proposal_pdf(pdf_id, state=None, state_prev=None, state_is_system=False, _test_skip_check=False)¶
Update the record for a PDF attached to a proposal.
- update_queue(queue_id, name=None, code=None, description=None, description_format=None, _test_skip_check=False)¶
Update a queue record.
- _get_proposal_text_id(conn, table, proposal_id, role)¶
Test whether text of the given role already exists for a proposal, and if it does, returns its identifier.
- _get_call_preamble_id(conn, semester_id, type_)¶
Test whether a preamble for the given semester and call type exists, and if it does, returns its identifier.
- _exists_queue_affiliation(conn, queue_id, affiliation_id)¶
Test whether an identifier exists in the given table.
hedwig.db.part.review¶
- class hedwig.db.part.review.ReviewPart¶
- add_group_member(queue_id, group_type, person_id, _conn=None, _test_skip_check=False)¶
- add_reviewer(role_class, proposal_id, person_id, role, _test_skip_check=False, _conn=None)¶
- add_reviewer_acceptance(role_class, proposal_id, person_id, role, accepted, text, format_, _conn=None)¶
- add_review_figure(reviewer_id, type_, figure, caption, filename, uploader_person_id, _test_skip_check=False)¶
- delete_affiliation_weight_note(call_id, _conn=None)¶
- delete_available_note(call_id, _conn=None)¶
- delete_reviewer(reviewer_id=None, proposal_id=None, person_id=None, role=None, delete_review=False, _conn=None)¶
Delete a reviewer record from the database.
This can, optionally, also delete any associated review. This is because, in the database, review.reviewer references reviewer.id with “ondelete” set to restrict. (We don’t want to accidentally delete reviews when working with th reviewer table.) The option allows the deletion to be “cascaded” manually when necessary.
Either selects the reviewer to delete by the “reviewer_id” argument, if it is specified, or, otherwise, by the proposal_id, person_id and role, all of whic must be specified together.
- delete_reviewer_acceptance(reviewer_acceptance_id, _conn=None)¶
Delete a reviewer acceptance explanation record.
- delete_reviewer_note(reviewer_id, _conn=None)¶
- _delete_note(table, key_column, key_value, _conn)¶
- delete_review_figure(reviewer_id, id_)¶
- get_affiliation_weight_note(call_id, _conn=None)¶
- get_available_note(call_id, _conn=None)¶
- _get_note(table, key_column, key_value, _conn)¶
- get_review_figure(reviewer_id, link_id, fig_id=None, md5sum=None)¶
- get_review_figure_preview(reviewer_id, link_id, fig_id=None, md5sum=None)¶
- get_review_figure_thumbnail(reviewer_id, link_id, fig_id=None, md5sum=None)¶
- multiple_reviewer_update(role_class, remove=None, add=None)¶
Perform multiple reviewer updates.
This is so that multiple updates to the reviewer assignment table can be prepared and then carried out (here) in a single transaction. The removals are performed first to avoid triggering the uniqueness constraint when the reviewer for a “unique” role is being changed.
The “role_class” for the relevant facility must be provided – this will be passed to “add_reviewer”.
“remove” and “add” are lists of kwargs dictionaries to be passed to “delete_reviewer” and “add_reviewer” respectively.
- search_group_member(queue_id=None, group_type=None, person_id=None, facility_id=None, group_member_id=None, with_person=False, with_queue=False, _conn=None)¶
- search_reviewer(proposal_id=None, role=None, reviewer_id=None, person_id=None, review_state=None, call_id=None, queue_id=None, proposal_state=None, institution_id=None, notified=None, accepted=(), thanked=(), with_review=False, with_review_text=False, with_review_note=False, with_invitation=False, with_acceptance=False, with_note=False, _conn=None)¶
- _expr_review_state()¶
- search_reviewer_acceptance(reviewer_acceptance_id=None, proposal_id=None, person_id=None, role=None, with_text=False, _conn=None)¶
- search_review_deadline(call_id=None, role=None, _conn=None)¶
Search for review deadlines.
- search_review_figure(reviewer_id=None, state=None, link_id=None, fig_id=None, with_caption=False, with_uploader_name=False, with_has_preview=False, order_by_date=False, no_link=False)¶
- set_affiliation_weight_note(call_id, note=None, format_=None, _conn=None)¶
- set_available_note(call_id, note=None, format_=None, _conn=None)¶
- set_decision(proposal_id, accept=(), exempt=None, ready=None, note=None, note_format=None)¶
- set_review(role_class, reviewer_id, text, format_, assessment, rating, weight, note, note_format, note_public, state)¶
- set_review_figure_preview(fig_id, preview)¶
- set_review_figure_thumbnail(fig_id, thumbnail)¶
- set_reviewer_note(reviewer_id, note=None, format_=None, _conn=None)¶
- _set_note(parent_table, table, key_column, key_value, note, format_, _conn)¶
- sync_call_review_deadline(role_class, call_id, records, _conn=None)¶
Update the review deadlines for a call.
- sync_group_member(queue_id, group_type, records)¶
Update the member records of the given group for the given queue.
Currently this just allows removing members of the group, but could be extended if group members gain extra attributes. (E.g. the chair of a group representing a committee.)
- sync_review_figure(reviewer_id, records)¶
Update the figures for a review.
Currently only deleting figures and changing the sort order is supported.
- update_reviewer(role_class, reviewer_id, notified=None, accepted=(), thanked=())¶
Update the status information of a reviewer record.
- update_reviewer_acceptance(reviewer_acceptance_id, accepted=None, text=None, format_=None, _conn=None)¶
- update_review_figure(reviewer_id, link_id, fig_id=None, figure=None, type_=None, filename=None, uploader_person_id=None, state=None, state_prev=None, caption=None, state_is_system=False)¶
Update the record of a figure attached to a review.
Can be used to update the figure or the state.
If the figure is updated, then the type, filename and uploader must be specified and the state will be set to NEW – the state must not be specifed explicitly.
- Returns:
the internal figure ID (not link ID) if it changed, for test purposes only
- _exists_note(conn, key_column, key_value)¶
Test whether the given note exists.
- _exists_reviewer(conn, proposal_id, role, person_id=None)¶
Test whether a reviewer record of the given role already exists for a proposal.
- _exists_review(conn, reviewer_id)¶
Test whether a review record by the given reviewer exists.