Commit 315f17aa by Arturo Montejo Ráez

Merge branch 'develop' of http://scm.ujaen.es/softuno/pictogram into develop

parents 406ba850 258604d1
......@@ -244,7 +244,7 @@ public class RestapiWrapper {
@Override
protected HttpAsyncTaskParams doInBackground(HttpAsyncTaskParams... params) {
try {
Log.i(com.yottacode.net.RestapiWrapper.class.getName(), " asking to the server for " + params[0].url+" params:"+params[0].url_params +" "+params[0].json_params);
Log.i(com.yottacode.net.RestapiWrapper.class.getName(), " asking to the server for " + params[0].url+" params:"+params[0].url_params +" JSON?"+params[0].json_params);
JSONObject jresult = params[0].request_method.equalsIgnoreCase("GET")
? GET(params[0].url, params[0].url_params)
: POST(params[0].url, params[0].request_method, params[0].url_params, params[0].json_params);
......
......@@ -158,12 +158,12 @@ public class Vocabulary implements Iterable<Picto> {
final String jexpression_text = "text";
Picto[] pictos = new Picto[result.length()];
JSONObject picto = null;
try {
JSONObject picto = null, expression = null, attributes = null;
try {
for (int i = 0; i < result.length(); i++) {
picto = result.getJSONObject(i).getJSONObject(jpicto);
JSONObject expression = result.getJSONObject(i).getJSONObject(jexpression);
JSONObject attributes = result.getJSONObject(i).getJSONObject(jattributes);
expression = result.getJSONObject(i).getJSONObject(jexpression);
attributes = result.getJSONObject(i).getJSONObject(jattributes);
pictos[i] = new Picto(picto.getInt(jid),
picto.getString(juri),
expression.getString(jexpression_text),
......@@ -173,8 +173,11 @@ public class Vocabulary implements Iterable<Picto> {
PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this);
Log.i(this.getClass().getName(), " Pictos downloaded: " + result.length());
} catch (JSONException e) {
Log.e(this.getClass().getName(), " Picto json error from server: " + picto.toString());
this.error(e);
StackTraceElement traces[] = e.getStackTrace();
for (StackTraceElement s: traces)
Log.e(s.getClassName()+"."+s.getFileName()+"."+s.getLineNumber(),s.toString());
Log.e(this.getClass().getName(), " Picto json error from server: " + picto.toString()+" expression:"+expression.toString()+" attributes:"+attributes.toString());
this.error(e);
}
}
}
......
......@@ -748,8 +748,13 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
this.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row);
this.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col);
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
this.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row);
this.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col);
} else {
this.getIntent().putExtra(Picto.JSON_ATTTRS.FREE_ROW, row);
this.getIntent().putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col);
}
startActivityForResult(intent, SELECT_PICTURE);
......@@ -773,7 +778,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int cat = PictogramActivity.this.currentCategory != null || !PCBcontext.getPcbdb().getCurrentUser().has_categories()
int cat = PictogramActivity.this.currentCategory != null
? PictogramActivity.this.currentCategory.get_id()
: Picto.NO_CATEGORY;
PCBcontext.getVocabulary().saveLocalPicto(
......
......@@ -98,11 +98,17 @@ public class PictoUploader {
private void uploadAttributes(int id_picto) {
Hashtable<String, String> params = new Hashtable<String, String>(4);
try {
params.put("json", new JSONObject().put("attributes",
(new JSONObject().put("id_cat", picto.get_category())
.put("coord_x", picto.get_column())
.put("coord_y", picto.get_row())
.put("status",picto.get_status()))).toString());
JSONObject json_attrs =new JSONObject().put("status",picto.get_status());
if (PCBcontext.getPcbdb().getCurrentUser().has_categories())
json_attrs.put(Picto.JSON_ATTTRS.CATEGORY, picto.get_category())
.put(Picto.JSON_ATTTRS.COLUMN, picto.get_column())
.put(Picto.JSON_ATTTRS.ROW, picto.get_row());
else
json_attrs.put(Picto.JSON_ATTTRS.CATEGORY, picto.NO_CATEGORY)
.put(Picto.JSON_ATTTRS.FREE_COLUMN, picto.getFreeColumn())
.put(Picto.JSON_ATTTRS.FREE_ROW, picto.getFreeRow());
params.put("json", new JSONObject().put("attributes",json_attrs).toString());
} catch (JSONException e) {
e.printStackTrace();
Log.e(this.getClass().getCanonicalName(), " Error: " + e.getLocalizedMessage());
......@@ -135,7 +141,7 @@ public class PictoUploader {
*/
private void uploadTranslation( int id_picto) {
Hashtable<String, String> params = new Hashtable<String, String>(3);
final Hashtable<String, String> params = new Hashtable<String, String>(3);
params.put("picto", Integer.toString(id_picto));
params.put("lang", PCBcontext.getPcbdb().getCurrentUser().get_lang_stu());
params.put("text", picto.get_translation());
......@@ -155,7 +161,7 @@ public class PictoUploader {
@Override
public void error(Exception e) {
Log.e(this.getClass().getCanonicalName(), "Error: " + e.getLocalizedMessage());
Log.e(this.getClass().getCanonicalName(), "Error uploading translation: " + e.getLocalizedMessage()+" Picto:"+params.get("picto")+" Lang:"+params.get("lang")+" Text:"+params.get("text"));
PCBcontext.getVocabulary().addPicto(picto, ImgDownloader.tsource.local);
}
});
......
......@@ -136,7 +136,7 @@ module.exports = {
supervisor.active = true;
delete supervisor.password;
supervisor.save();
return res.view('accountActivated', {sup: supervisor, login_url: req.protocol + '://' + req.headers.host + '/app'});
return res.view('accountActivated', {sup: supervisor, login_url: 'https://' + req.headers.host + '/app'});
})
.catch(function (err) {
return res.serverError("Error when activating account " + err);
......@@ -236,7 +236,7 @@ module.exports = {
var message = sails.__({
phrase: 'signin_mail',
locale: params.lang || 'es-es'
}) + req.protocol + '://' + req.headers.host + '/sup/activate/' + sailsTokenAuth.issueToken(supervisor.id, 60*24*7); // expires in 1 week
}) + 'https://' + req.headers.host + '/sup/activate/' + sailsTokenAuth.issueToken(supervisor.id, 60*24*7); // expires in 1 week
sails.log.debug("Sending activation email: \n" + message);
mailService.mailer()
......
......@@ -245,7 +245,7 @@
"students": "Alumnos",
"sup_not_added": "El supervisor no se ha podido añadir al estudiante.",
"sup_not_deleted": "El supervisor no se ha podido desvincular del alumno.",
"sup_not_found": "No hay ningún supervisor en Pictogram con ese correo electrónico.",
"sup_not_found": "No hay ningún usuario en Pictogram con ese correo electrónico.",
"supervisor_added": "Supervisor añadido",
"supervisor_deleted": "Supervisor eliminado",
"supervisor_not_added": "Supervisor no añadido",
......
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