diff --git a/web/App_GlobalResources/LocalizedText.fr.resx b/web/App_GlobalResources/LocalizedText.fr.resx
index cb70d4c8..f3d78e6d 100644
--- a/web/App_GlobalResources/LocalizedText.fr.resx
+++ b/web/App_GlobalResources/LocalizedText.fr.resx
@@ -20,4 +20,11 @@
Hors ligne
Non approuvé
Supprimer
+ Version Pdf
+ Version LaTeX
+ Nom d'utilisateur
+ Description
+ Référence produit
+ Coût unitaire
+ Nombre
diff --git a/web/App_GlobalResources/LocalizedText.resx b/web/App_GlobalResources/LocalizedText.resx
index e1dbb0e8..77c719db 100644
--- a/web/App_GlobalResources/LocalizedText.resx
+++ b/web/App_GlobalResources/LocalizedText.resx
@@ -20,4 +20,12 @@
Offline
Not Approuved
Remove
+ Pdf version
+ LaTeX version
+ User name
+
+ Description
+ Product_reference
+ Unitary_cost
+ Count
diff --git a/web/Controllers/FrontOfficeApiController.cs b/web/Controllers/FrontOfficeApiController.cs
index da70397c..69927b78 100644
--- a/web/Controllers/FrontOfficeApiController.cs
+++ b/web/Controllers/FrontOfficeApiController.cs
@@ -86,16 +86,16 @@ namespace Yavsc.ApiControllers
}
[AcceptVerbs("GET")]
- public HttpResponseMessage GetTexEstim(long estimid)
+ public HttpResponseMessage GetEstimTex(long estimid)
{
return new HttpResponseMessage () {
Content = new ObjectContent (typeof(string),
- getTexEstim (estimid),
- new TexFormatter ())
+ getEstimTex (estimid),
+ new SimpleFormatter ("text/x-tex"))
};
}
- private string getTexEstim(long estimid)
+ private string getEstimTex(long estimid)
{
Yavsc.templates.Estim tmpe = new Yavsc.templates.Estim();
Estimate e = WorkFlowManager.GetEstimate (estimid);
diff --git a/web/Controllers/FrontOfficeController.cs b/web/Controllers/FrontOfficeController.cs
index c6fc4b1b..73e8d693 100644
--- a/web/Controllers/FrontOfficeController.cs
+++ b/web/Controllers/FrontOfficeController.cs
@@ -30,6 +30,8 @@ namespace Yavsc.Controllers
[Authorize]
public ActionResult Estimate(Estimate model,string submit)
{
+ ViewData ["WebApiBase"] = "http://" + Request.Url.Authority + "/api";
+ ViewData ["WABASEWF"] = ViewData ["WebApiBase"] + "/WorkFlow";
if (submit == null) {
if (model.Id > 0) {
Estimate f = WorkFlowManager.GetEstimate (model.Id);
@@ -41,27 +43,31 @@ namespace Yavsc.Controllers
ModelState.Clear ();
string username = HttpContext.User.Identity.Name;
if (username != model.Responsible
- && username != model.Client
- && !Roles.IsUserInRole ("FrontOffice"))
+ && username != model.Client
+ && !Roles.IsUserInRole ("FrontOffice"))
throw new UnauthorizedAccessException ("You're not allowed to view this estimate");
}
- } else if (ModelState.IsValid) {
-
- ViewData ["WebApiUrl"] = "http://" + Request.Url.Authority + "/api/WorkFlow";
+ } else {
string username = HttpContext.User.Identity.Name;
- if (username != model.Responsible
- && username != model.Client
- && !Roles.IsUserInRole ("FrontOffice"))
- throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");
+ if (model.Id == 0) {
+ model.Responsible=username;
+ ModelState.Clear ();
+ }
+ if (ModelState.IsValid) {
+ if (username != model.Responsible
+ && username != model.Client
+ && !Roles.IsUserInRole ("FrontOffice"))
+ throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");
- if (model.Id == 0)
+ if (model.Id == 0)
model = WorkFlowManager.CreateEstimate (
username,
model.Client, model.Title, model.Description);
else
WorkFlowManager.UpdateEstimate (model);
+ }
}
return View(model);
}
diff --git a/web/Controllers/WorkFlowController.cs b/web/Controllers/WorkFlowController.cs
index fc2eb876..5571a8b9 100644
--- a/web/Controllers/WorkFlowController.cs
+++ b/web/Controllers/WorkFlowController.cs
@@ -38,14 +38,17 @@ namespace Yavsc.ApiControllers
{
WorkFlowManager.DropWritting (wrid);
}
+ class Error {}
[Authorize]
[AcceptVerbs("POST")]
- public void UpdateWritting([FromBody] Writting wr)
+ public object UpdateWritting([FromBody] Writting model)
{
- if (!ModelState.IsValid)
- throw new Exception ("Modèle invalide");
- WorkFlowManager.UpdateWritting (wr);
+ if (!ModelState.IsValid) {
+ return ModelState.Where ( k => k.Value.Errors.Count>0) ;
+ }
+ WorkFlowManager.UpdateWritting (model);
+ return null;
}
[HttpGet]
@@ -67,8 +70,12 @@ namespace Yavsc.ApiControllers
[AcceptVerbs("POST")]
[Authorize]
- public long Write ([FromUri] long estid, [FromBody] Writting wr) {
- // TODO ensure estid owner matches the current one
+ ///
+ /// Adds the specified imputation to the given estimation by estimation id.
+ ///
+ /// Estimation identifier
+ /// Imputation to add
+ public long Write ([FromUri] long estid, Writting wr) {
return WorkFlowManager.Write(estid, wr.Description,
wr.UnitaryCost, wr.Count, wr.ProductReference);
}
diff --git a/web/Formatters/TexFormatter.cs b/web/Formatters/TexFormatter.cs
index 671e3b80..1db1a974 100644
--- a/web/Formatters/TexFormatter.cs
+++ b/web/Formatters/TexFormatter.cs
@@ -27,12 +27,11 @@ using System.Net.Http;
namespace Yavsc.Formatters
{
- public class TexFormatter : BufferedMediaTypeFormatter
+ public class SimpleFormatter : BufferedMediaTypeFormatter
{
- public TexFormatter ()
+ public SimpleFormatter (string mimetype)
{
- SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/x-tex"));
-
+ SupportedMediaTypes.Add(new MediaTypeHeaderValue(mimetype));
}
public override bool CanWriteType(System.Type type)
diff --git a/web/Global.asax.cs b/web/Global.asax.cs
index 5f29a41f..c361fc87 100644
--- a/web/Global.asax.cs
+++ b/web/Global.asax.cs
@@ -44,7 +44,7 @@ namespace Yavsc
protected void Application_Start ()
{
AreaRegistration.RegisterAllAreas ();
- GlobalConfiguration.Configuration.Formatters.Add (new TexFormatter ());
+ // add formatters : GlobalConfiguration.Configuration.Formatters.Add (new ZeroFormatter ());
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{*id}",
diff --git a/web/Helpers/BBCodeHelper.cs b/web/Helpers/BBCodeHelper.cs
index 421ed6b5..c7eb85b3 100644
--- a/web/Helpers/BBCodeHelper.cs
+++ b/web/Helpers/BBCodeHelper.cs
@@ -148,7 +148,9 @@ namespace Yavsc.Helpers
}
}
}
- return ttb.ToString ();
+ TagBuilder aside = new TagBuilder ("aside");
+ aside.InnerHtml = ttb.ToString ();
+ return aside.ToString();
}
static string DocPageContentTransformer (string instr)
diff --git a/web/Models/App.master b/web/Models/App.master
index c04dde83..eb8e7726 100644
--- a/web/Models/App.master
+++ b/web/Models/App.master
@@ -56,7 +56,7 @@