- added a header with some basic information to the event form ( addressed issue #12 )

- when invalid event data is submitted, an "internal processing error" (900) is now thrown ( addressed issue #15 )
This commit is contained in:
Dorian Zedler 2018-12-27 11:06:26 +01:00
parent f7d5a111d0
commit 74b9233a9e
2 changed files with 19 additions and 10 deletions

View file

@ -71,7 +71,7 @@ Page {
right: parent.right right: parent.right
top: parent.top top: parent.top
margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3 margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3
topMargin: parent.height/2 - height * 0.8 topMargin: parent.height*( status === 901 ? 0.6:0.5) - height * 0.8
} }
errorCode: status errorCode: status

View file

@ -254,13 +254,6 @@ int ServerConn::getEvents(QString day){
this->progress = 1; this->progress = 1;
if(status_code != 200){ if(status_code != 200){
// if the request didn't result in a success, return the error code // if the request didn't result in a success, return the error code
// if the request failed but there is still old data available
if(!this->m_events.isEmpty()){
// set the status code to 902 (old data)
status_code = 902;
}
return(status_code.toInt()); return(status_code.toInt());
} }
@ -411,6 +404,20 @@ int ServerConn::getEvents(QString day){
tmpEventHeader.append(""); tmpEventHeader.append("");
} }
// check if the header is valid
// variable to count filled blocks
int blocksOK = 0;
foreach(QString block, tmpEventHeader){
if(block != ""){
blocksOK ++;
}
}
if(blocksOK != 3) {
// if there are more or less than 3 filled blocks, the data is invalid
return(900);
}
// swap creation and target date // swap creation and target date
tmpEventHeader.swap(0,1); tmpEventHeader.swap(0,1);
@ -448,8 +455,10 @@ int ServerConn::getEvents(QString day){
qDebug() << tmpEvents; qDebug() << tmpEvents;
// check if there is any valid data // check if there is any valid data
if(this->m_events.isEmpty()){ if(this->m_events.length() < 3){
// no data // remove the last (in this case the second) element, as it is unnecessary
m_events.takeLast();
// return no data
return(901); return(901);
} }