2017-06-28 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in 'web/rdxport/carts.cpp' and 'web/rdxport/import.cpp'
	that caused the 'EditCart' web API call to return an error when
	attempting to set the Title field to its current value when
	Allow Duplicate Cart Titles was not enabled.
This commit is contained in:
Fred Gleason 2017-06-28 14:05:43 -04:00
parent ce40efc569
commit bec5067090
5 changed files with 12 additions and 6 deletions

View File

@ -15876,3 +15876,8 @@
2017-06-28 Fred Gleason <fredg@paravelsystems.com> 2017-06-28 Fred Gleason <fredg@paravelsystems.com>
* Added code to rdexport(1) to write the name of each file written * Added code to rdexport(1) to write the name of each file written
to standard output. to standard output.
2017-06-28 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in 'web/rdxport/carts.cpp' and 'web/rdxport/import.cpp'
that caused the 'EditCart' web API call to return an error when
attempting to set the Title field to its current value when
Allow Duplicate Cart Titles was not enabled.

View File

@ -2011,12 +2011,13 @@ QString RDCart::uniqueCartTitle(unsigned cartnum)
} }
bool RDCart::titleIsUnique(const QString &str) bool RDCart::titleIsUnique(unsigned except_cartnum,const QString &str)
{ {
bool ret=false; bool ret=false;
QString sql=QString("select NUMBER from CART where ")+ QString sql=QString("select NUMBER from CART where ")+
"TITLE=\""+RDEscapeString(str)+"\""; "(TITLE=\""+RDEscapeString(str)+"\")&&"+
QString().sprintf("NUMBER!=%u",except_cartnum);
RDSqlQuery *q=new RDSqlQuery(sql); RDSqlQuery *q=new RDSqlQuery(sql);
ret=!q->first(); ret=!q->first();
delete q; delete q;

View File

@ -167,7 +167,7 @@ class RDCart
static void removePending(RDStation *station,RDUser *user,RDConfig *config); static void removePending(RDStation *station,RDUser *user,RDConfig *config);
static unsigned readXml(std::vector<RDWaveData> *data,const QString &xml); static unsigned readXml(std::vector<RDWaveData> *data,const QString &xml);
static QString uniqueCartTitle(unsigned cartnum=0); static QString uniqueCartTitle(unsigned cartnum=0);
static bool titleIsUnique(const QString &str); static bool titleIsUnique(unsigned except_cartnum,const QString &str);
private: private:
static QVariant GetXmlValue(const QString &tag,const QString &line); static QVariant GetXmlValue(const QString &tag,const QString &line);

View File

@ -315,7 +315,7 @@ void Xport::EditCart()
if(xport_post->getValue("TITLE",&value)) { if(xport_post->getValue("TITLE",&value)) {
if((!xport_system->allowDuplicateCartTitles())&& if((!xport_system->allowDuplicateCartTitles())&&
(!xport_system->fixDuplicateCartTitles())&& (!xport_system->fixDuplicateCartTitles())&&
(!RDCart::titleIsUnique(value))) { (!RDCart::titleIsUnique(cart_number,value))) {
XmlExit("Duplicate Cart Title Not Allowed",404,"carts.cpp",LINE_NUMBER); XmlExit("Duplicate Cart Title Not Allowed",404,"carts.cpp",LINE_NUMBER);
} }
cart->setTitle(value); cart->setTitle(value);

View File

@ -115,7 +115,7 @@ void Xport::Import()
if(!title.isEmpty()) { if(!title.isEmpty()) {
if((!xport_system->allowDuplicateCartTitles())&& if((!xport_system->allowDuplicateCartTitles())&&
(!xport_system->fixDuplicateCartTitles())&& (!xport_system->fixDuplicateCartTitles())&&
(!RDCart::titleIsUnique(title))) { (!RDCart::titleIsUnique(cartnum,title))) {
XmlExit("Duplicate Cart Title Not Allowed",404,"import.cpp",LINE_NUMBER); XmlExit("Duplicate Cart Title Not Allowed",404,"import.cpp",LINE_NUMBER);
} }
} }
@ -178,7 +178,7 @@ void Xport::Import()
if(use_metadata) { if(use_metadata) {
if((!xport_system->allowDuplicateCartTitles())&& if((!xport_system->allowDuplicateCartTitles())&&
(!xport_system->fixDuplicateCartTitles())&& (!xport_system->fixDuplicateCartTitles())&&
(!RDCart::titleIsUnique(wavedata.title()))) { (!RDCart::titleIsUnique(cartnum,wavedata.title()))) {
XmlExit("Duplicate Cart Title Not Allowed",404,"import.cpp",LINE_NUMBER); XmlExit("Duplicate Cart Title Not Allowed",404,"import.cpp",LINE_NUMBER);
} }
} }