[chronojump] CompujumpDjango on config.cs to download correctly images
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] CompujumpDjango on config.cs to download correctly images
- Date: Fri, 21 Jun 2019 10:05:57 +0000 (UTC)
commit 23f5438b1776a7f51e960b6897c0e558d308a485
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Jun 21 12:04:28 2019 +0200
CompujumpDjango on config.cs to download correctly images
howto_compujump_client.txt | 4 ++++
src/config.cs | 8 ++++----
src/gui/chronojump.cs | 2 +-
src/gui/dialogPersonPopup.cs | 6 ++++--
src/gui/encoder.cs | 2 +-
src/gui/networks.cs | 7 ++++---
src/json/compujump.cs | 17 ++++++++++++-----
7 files changed, 30 insertions(+), 16 deletions(-)
---
diff --git a/howto_compujump_client.txt b/howto_compujump_client.txt
index 82f0e076..13979d89 100644
--- a/howto_compujump_client.txt
+++ b/howto_compujump_client.txt
@@ -60,6 +60,10 @@ SessionMode=MONTHLY
#Use Compujump
Compujump=TRUE
+
+#if is Django uncomment this line:
+CompujumpDjango=TRUE
+
CompujumpServerURL=http://127.0.0.1:8080
CompujumpStationID=1
diff --git a/src/config.cs b/src/config.cs
index dfae45cc..b0226801 100644
--- a/src/config.cs
+++ b/src/config.cs
@@ -38,8 +38,9 @@ public class Config
public bool EncoderAnalyzeHide;
public SessionModeEnum SessionMode;
public bool Compujump;
+ public bool CompujumpDjango;
public string CompujumpServerURL = "";
- public int CompujumpOrganizationID = -1; //Django stations have OrganizationID 1 or more
+
public int CompujumpStationID = -1;
public int CompujumpAdminID = -1; //undefined
public string CompujumpAdminEmail = ""; //undefined
@@ -76,7 +77,6 @@ public class Config
public void Read()
{
- string contents = Util.ReadFile(UtilAll.GetConfigFileName(), false);
if (contents != null && contents != "")
{
string line;
@@ -95,10 +95,10 @@ public class Config
if(parts[0] == "Compujump" && Util.StringToBool(parts[1]))
Compujump = true;
+ else if(parts[0] == "CompujumpDjango" && Util.StringToBool(parts[1]))
+ CompujumpDjango = true;
else if(parts[0] == "CompujumpServerURL" && parts[1] != "")
CompujumpServerURL = parts[1];
- else if(parts[0] == "CompujumpOrganizationID" && parts[1] != "" &&
Util.IsNumber(parts[1], false))
- CompujumpOrganizationID = Convert.ToInt32(parts[1]);
else if(parts[0] == "CompujumpStationID" && parts[1] != "" &&
Util.IsNumber(parts[1], false))
CompujumpStationID = Convert.ToInt32(parts[1]);
else if(parts[0] == "CompujumpAdminID" && parts[1] != "" &&
Util.IsNumber(parts[1], false))
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index d385bc1d..16921acd 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -4938,7 +4938,7 @@ public partial class ChronoJumpWindow
sprint.Positions, sprint.GetSplitTimesAsList(),
k, vmax, amax, fmax, pmax);
- JsonCompujump js = new JsonCompujump();
+ JsonCompujump js = new JsonCompujump(configChronojump.CompujumpDjango);
if( ! js.UploadSprintData(usdo) )
{
LogB.Error(js.ResultMessage);
diff --git a/src/gui/dialogPersonPopup.cs b/src/gui/dialogPersonPopup.cs
index 18c04de0..89e191cd 100644
--- a/src/gui/dialogPersonPopup.cs
+++ b/src/gui/dialogPersonPopup.cs
@@ -53,9 +53,10 @@ public class DialogPersonPopup
public Button Fake_button_person_autologout_changed;
public bool Visible;
public bool Autologout;
+ private bool compujumpDjango;
public DialogPersonPopup (int personID, string name, string rfid,
- List<Task> tasks, List<StationCount> stationsCount, bool serverConnected, bool
Autologout)
+ List<Task> tasks, List<StationCount> stationsCount, bool serverConnected, bool
Autologout, bool compujumpDjango)
{
Glade.XML gladeXML;
gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "dialog_person_popup.glade",
"dialog_person_popup", null);
@@ -66,6 +67,7 @@ public class DialogPersonPopup
Visible = true;
this.Autologout = Autologout;
+ this.compujumpDjango = compujumpDjango;
//1) Show top of the window widgets
label_name.Text = "<b>" + name + "</b>";
@@ -252,7 +254,7 @@ public class DialogPersonPopup
{
LogB.Information("Clicked button done: " + count.ToString());
- JsonCompujump json = new JsonCompujump();
+ JsonCompujump json = new JsonCompujump(compujumpDjango);
json.UpdateTask(list_buttons_done_id[count], 1);
//button.Sensitive = false;
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 61d0894a..a7a7ae10 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -7000,7 +7000,7 @@ public partial class ChronoJumpWindow
*/
LogB.Information("calling Upload");
- JsonCompujump js = new JsonCompujump();
+ JsonCompujump js = new
JsonCompujump(configChronojump.CompujumpDjango);
UploadEncoderDataFullObject uedfo = new
UploadEncoderDataFullObject(
-1, //uniqueID
currentPerson.UniqueID,
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 2416b106..57f9fc61 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -578,7 +578,7 @@ public partial class ChronoJumpWindow
bool currentPersonWasNull = (currentPerson == null);
bool pChangedShowTasks = false;
- JsonCompujump json = new JsonCompujump();
+ JsonCompujump json = new JsonCompujump(configChronojump.CompujumpDjango);
//select person by RFID
Person pLocal = SqlitePerson.SelectByRFID(capturedRFID);
@@ -776,7 +776,7 @@ public partial class ChronoJumpWindow
private void getTasksExercisesAndPopup()
{
//1) get tasks
- JsonCompujump json = new JsonCompujump();
+ JsonCompujump json = new JsonCompujump(configChronojump.CompujumpDjango);
List<Task> tasks = json.GetTasks(currentPerson.UniqueID, configChronojump.CompujumpStationID);
//2) get exercises and insert if needed (only on encoder)
@@ -823,7 +823,8 @@ public partial class ChronoJumpWindow
dialogPersonPopup = new DialogPersonPopup(
currentPerson.UniqueID, currentPerson.Name, capturedRFID, tasks,
stationsCount,
- serverConnected, compujumpAutologout.Active);
+ serverConnected, compujumpAutologout.Active,
+ configChronojump.CompujumpDjango);
dialogPersonPopup.Fake_button_start_task.Clicked -= new EventHandler(compujumpTaskStart);
dialogPersonPopup.Fake_button_start_task.Clicked += new EventHandler(compujumpTaskStart);
diff --git a/src/json/compujump.cs b/src/json/compujump.cs
index 1c943a49..51601041 100644
--- a/src/json/compujump.cs
+++ b/src/json/compujump.cs
@@ -31,8 +31,12 @@ using Mono.Unix;
public class JsonCompujump : Json
{
- public JsonCompujump()
+ private bool django;
+
+ public JsonCompujump(bool django)
{
+ this.django = django;
+
ResultMessage = "";
}
@@ -53,6 +57,7 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
+
json.Add("rfid", rfid);
// Converts it to a String
@@ -129,7 +134,11 @@ public class JsonCompujump : Json
private string getImagesUrl()
{
int posOfLastColon = serverUrl.LastIndexOf(':');
- return serverUrl.Substring(0, posOfLastColon) + ":5000/static/images/photos/";
+
+ if(django)
+ return serverUrl.Substring(0, posOfLastColon) + ":8000/media/";
+ else
+ return serverUrl.Substring(0, posOfLastColon) + ":5000/static/images/photos/";
}
//imageHalfUrl is "jugadors/*.jpg"
@@ -168,6 +177,7 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
+
json.Add("personId", personID.ToString());
json.Add("stationId", stationID.ToString());
@@ -248,7 +258,6 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
-
json.Add("taskId", taskId);
json.Add("done", done);
@@ -515,7 +524,6 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
-
json.Add("personId", o.personId);
json.Add("distances", o.sprintPositions);
json.Add("t1", o.splitTimesL[1]);
@@ -593,7 +601,6 @@ public class JsonCompujump : Json
// Creates the json object
JsonObject json = new JsonObject();
-
json.Add("personId", o.personId);
json.Add("stationId", o.stationId);
//json.Add("exerciseName", exerciseName);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]