Commit 32790c89 by Arturo Montejo Ráez

Merge branch 'develop' into tpv

parents e942d14e 62dcb069
...@@ -13,13 +13,11 @@ import com.yottacode.pictogram.net.websockets.Room; ...@@ -13,13 +13,11 @@ import com.yottacode.pictogram.net.websockets.Room;
*/ */
public class SubscribeAction extends Action { public class SubscribeAction extends Action {
//Picto Action types //Picto Action types
public static final String SUBSCRIBE="subscribe"; public static final String SUBSCRIBE="subscribe";
public static final String ACTION="/stu/subscribe"; public static final String ACTION="/stu/subscribe";
@Override @Override
public boolean is_local_action() { public boolean is_local_action() {
return false; return false;
...@@ -29,6 +27,5 @@ public class SubscribeAction extends Action { ...@@ -29,6 +27,5 @@ public class SubscribeAction extends Action {
super(SUBSCRIBE); super(SUBSCRIBE);
} }
public String get_action() {return ACTION;} public String get_action() {return ACTION;}
} }
...@@ -184,9 +184,11 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -184,9 +184,11 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
//cada restfullSynchroTimming aprox. se fuerza sincronización de vocabulario y configuración de usuario //cada restfullSynchroTimming aprox. se fuerza sincronización de vocabulario y configuración de usuario
long now = new Date().getTime(); long now = new Date().getTime();
if (PCBcontext.is_user_logged()) { if (PCBcontext.is_user_logged()) {
if (restfullSynchroTimming > 0 && (now>= nextRestfullSynchro)) { if (restfullSynchroTimming > 0 && (now >= nextRestfullSynchro)) {
Log.i(LOG_TAG, "Vocabulary request."); Log.i(LOG_TAG, "Vocabulary request.");
if(!PCBcontext.getRoom().inRoom()){
PCBcontext.getRoom().connect(); PCBcontext.getRoom().connect();
}
PCBcontext.getVocabulary().synchronize(); PCBcontext.getVocabulary().synchronize();
synchronizeStudentAttributes(); synchronizeStudentAttributes();
nextSynchro(now+restfullSynchroTimming); nextSynchro(now+restfullSynchroTimming);
......
...@@ -121,16 +121,5 @@ ...@@ -121,16 +121,5 @@
<orderEntry type="library" exported="" name="play-services-ads-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-ads-9.2.1" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" />
<orderEntry type="module" module-name="commonlibrary" exported="" /> <orderEntry type="module" module-name="commonlibrary" exported="" />
<orderEntry type="library" exported="" name="okhttp-ws-2.3.0" level="project" />
<orderEntry type="library" exported="" name="socket.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.3.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="library" exported="" name="okio-1.3.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
<orderEntry type="library" exported="" name="engine.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="json-20090211" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -551,18 +551,20 @@ module.exports = { ...@@ -551,18 +551,20 @@ module.exports = {
* *
*/ */
link_supervisor: function (req, res) { link_supervisor: function (req, res) {
if (!req.params.id_off || !req.params.id_sup) var params = req.allParams();
if (!params.id_off || !params.id_sup)
return res.badRequest(); return res.badRequest();
if (req.params.id_off == req.params.id_sup) if (params.id_off == params.id_sup)
return res.badRequest("Link to yourself is not allowed"); return res.badRequest("Link to yourself is not allowed");
// Check that both ids are valid // Check that both ids are valid
Supervisor.findOne(req.params.id_sup) Supervisor.findOne(params.id_sup)
.then((sup) => { .then((sup) => {
if (!sup) if (!sup)
throw new Error("Supervisor not found"); throw new Error("Supervisor not found");
return [sup, Supervisor.findOne(req.params.id_off)]; return [sup, Supervisor.findOne(params.id_off)];
}) })
.spread((sup, off) => { .spread((sup, off) => {
if (!off) if (!off)
...@@ -601,20 +603,22 @@ module.exports = { ...@@ -601,20 +603,22 @@ module.exports = {
* *
*/ */
unlink_supervisor: function (req, res) { unlink_supervisor: function (req, res) {
if (!req.params.id_off || !req.params.id_sup) var params = req.allParams();
if (!params.id_off || !params.id_sup)
return res.badRequest(); return res.badRequest();
// Check that both ids are valid // Check that both ids are valid
Supervisor.findOne(req.params.id_sup) Supervisor.findOne(params.id_sup)
.then((s) => { .then((s) => {
if (!s) if (!s)
throw new Error("Supervisor not found"); throw new Error("Supervisor not found");
return Supervisor.findOne(req.params.id_off); return Supervisor.findOne(params.id_off);
}) })
.then((s) => { .then((s) => {
if (!s) if (!s)
throw new Error("Supervisor not found"); throw new Error("Supervisor not found");
return SupOff.destroy({supervisor: req.params.id_sup, office: req.params.id_off}); return SupOff.destroy({supervisor: params.id_sup, office: params.id_off});
}) })
.then((sos) => { .then((sos) => {
if (!sos) if (!sos)
......
...@@ -321,7 +321,7 @@ module.exports = { ...@@ -321,7 +321,7 @@ module.exports = {
if (!supOffs || supOffs.length == 0) { if (!supOffs || supOffs.length == 0) {
// if we get here, only the requester being directly related to the // if we get here, only the requester being directly related to the
// student is valid // student is valid
var supIdx = stuSups.findIndex(x => x.supervisor.id == id_sup); var supIdx = stuSups.findIndex(x => x.supervisor && x.supervisor.id == id_sup);
if (supIdx >= 0) if (supIdx >= 0)
return callback(null, [stuSups[supIdx].supervisor]); return callback(null, [stuSups[supIdx].supervisor]);
throw new Error("No supervisors related"); throw new Error("No supervisors related");
...@@ -329,12 +329,17 @@ module.exports = { ...@@ -329,12 +329,17 @@ module.exports = {
// filter null entries and map them to the supervisor object // filter null entries and map them to the supervisor object
var ss = _.compact(_.compact(stuSups).map(x => x.supervisor)); var ss = _.compact(_.compact(stuSups).map(x => x.supervisor)); // supervisors linked to student
var so = _.compact(_.compact(supOffs).map(x => x.supervisor)); var so = _.compact(_.compact(supOffs).map(x => x.supervisor)); // supervisors linked to office
// filter from the second list those found in the first list // filter from the second list those found in the first list
var sups = so.filter(a => ss.findIndex(b => b.id == a.id) >= 0); var sups = so.filter(a => ss.findIndex(b => b.id == a.id) >= 0);
return [sups, Supervisor.find(id_sup)];
})
.spread((sups, me) => {
// The requester is an office, so it has to be appended to the list of valid supervisors
sups.push(me[0]);
return callback(null, sups); return callback(null, sups);
}) })
.catch((err) => { .catch((err) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment