[Koha-bugs] [Bug 28701] primary_contact_method not part of the REST API spec

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jan 27 11:29:15 CET 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28701

Tomás Cohen Arazi <tomascohen at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|Passed QA                   |Failed QA

--- Comment #10 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
(In reply to Marcel de Rooy from comment #6)
> (In reply to Tomás Cohen Arazi from comment #5)
> > I think it should be an enum
> 
> `primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for
> reporting purposes',
> 
> Scope creep ?

If you git grep primary_contact_method, you will notice that the possible
values there are hardcoded:

koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt:                  
                             <select id="borrower_primary_contact_method" name
="borrower_primary_contact_method">
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt:                  
                                     [% IF ( borrower.primary_contact_method =
= 'phone' ) %]
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt:                  
                                     [% IF ( borrower.primary_contact_method =
= 'phonepro' ) %]
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt:                  
                                     [% IF ( borrower.primary_contact_method =
= 'mobile' ) %]
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt:                  
                                     [% IF ( borrower.primary_contact_method =
= 'email' ) %]
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt:                  
                                     [% IF ( borrower.primary_contact_method =
= 'emailpro' ) %]
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt:                  
                                     [% IF ( borrower.primary_contact_method =
= 'fax' ) %]

when we write endpoint specs, we want them to be future proof (as much as
possible). So I'm not expecting this bug to update the DB structure, but
either:

(a) make the type of the 'new API object attribute' be an enum with those
values
(b) choose better names for those hardcoded values, and list them as an enum IN
THE SPEC and make to_api() handle the name mapping.

I'd prefer (b).

Regarding the follow-up, it does the job, but we've better only map things that
need mapping (i.e. mapping to null removes it from the response, mapping to a
value makes the API translate the name, not mapping makes the API return it
as-is.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list