Browse Source

by default /group/1

master
pvincent 2 years ago
parent
commit
b2b7e88e3c
  1. 4
      src/App.hx
  2. 178
      src/controller/Group.hx
  3. 97
      src/controller/Main.hx
  4. 12
      src/service/WaitingListService.hx
  5. 1
      www/lang/texts_fr.po

4
src/App.hx

@ -203,7 +203,7 @@ class App extends sugoi.BaseApp {
out.set("percent", "Pourcentage"); out.set("percent", "Pourcentage");
out.set("pinned", "Mets en avant les produits"); out.set("pinned", "Mets en avant les produits");
out.set("CagetteNetwork", "Me lister dans l'annuaire");
out.set("CagetteNetwork", "Me lister dans l'annuaire des groupes");
out.set("unitType", "Unité"); out.set("unitType", "Unité");
out.set("qt", "Quantité"); out.set("qt", "Quantité");
out.set("Unit", "Pièce"); out.set("Unit", "Pièce");
@ -280,7 +280,7 @@ class App extends sugoi.BaseApp {
var e = new sugoi.mail.Mail(); var e = new sugoi.mail.Mail();
e.setSubject(subject); e.setSubject(subject);
e.setRecipient(to); e.setRecipient(to);
e.setSender(App.config.get("default_email"), t._("Cagette.net"));
e.setSender(App.config.get("default_email"), t._("CagettePéi"));
var html = App.current.processTemplate("mail/message.mtt", {text: html, group: group}); var html = App.current.processTemplate("mail/message.mtt", {text: html, group: group});
e.setHtmlBody(html); e.setHtmlBody(html);
App.sendMail(e); App.sendMail(e);

178
src/controller/Group.hx

@ -14,66 +14,66 @@ class Group extends controller.Controller
*/ */
@tpl('group/view.mtt') @tpl('group/view.mtt')
function doDefault(group:db.Amap){ function doDefault(group:db.Amap){
if (group.regOption == db.Amap.RegOption.Open) { if (group.regOption == db.Amap.RegOption.Open) {
app.session.data.amapId = group.id; app.session.data.amapId = group.id;
throw Redirect("/"); throw Redirect("/");
} }
view.group = group; view.group = group;
view.contracts = group.getActiveContracts(); view.contracts = group.getActiveContracts();
view.pageTitle = group.name; view.pageTitle = group.name;
group.getMainPlace(); //just to update cache group.getMainPlace(); //just to update cache
if (app.user != null){ if (app.user != null){
view.isMember = Lambda.has(app.user.getAmaps(), group); view.isMember = Lambda.has(app.user.getAmaps(), group);
} }
} }
/** /**
* Register to a waiting list. * Register to a waiting list.
* the user can be logged or not ! * the user can be logged or not !
*/ */
@tpl('form.mtt') @tpl('form.mtt')
function doList(group:db.Amap){ function doList(group:db.Amap){
//checks //checks
if (group.regOption != db.Amap.RegOption.WaitingList) throw Redirect("/group/" + group.id); if (group.regOption != db.Amap.RegOption.WaitingList) throw Redirect("/group/" + group.id);
if (app.user != null) { if (app.user != null) {
try{ try{
WaitingListService.canRegister(app.user,group); WaitingListService.canRegister(app.user,group);
}catch(e:tink.core.Error){
}catch(e:tink.core.Error){
throw Error("/group/" + group.id,e.message); throw Error("/group/" + group.id,e.message);
} }
} }
//build form //build form
var form = new sugoi.form.Form("reg");
var form = new sugoi.form.Form("reg");
if (app.user == null){ if (app.user == null){
form.addElement(new StringInput("userFirstName", t._("Your firstname"),"",true)); form.addElement(new StringInput("userFirstName", t._("Your firstname"),"",true));
form.addElement(new StringInput("userLastName", t._("Your lastname") ,"",true)); form.addElement(new StringInput("userLastName", t._("Your lastname") ,"",true));
form.addElement(new StringInput("userEmail", t._("Your e-mail"), "", true));
form.addElement(new StringInput("userEmail", t._("Your e-mail"), "", true));
} }
form.addElement(new sugoi.form.elements.TextArea("msg", t._("Leave a message")));
form.addElement(new sugoi.form.elements.TextArea("msg", t._("Leave a message"),"",false));
if (form.isValid()){ if (form.isValid()){
try{ try{
if (app.user == null){ if (app.user == null){
var f = form; var f = form;
var user = service.UserService.softRegistration(f.getValueOf("userFirstName"),f.getValueOf("userLastName"), f.getValueOf("userEmail") ); var user = service.UserService.softRegistration(f.getValueOf("userFirstName"),f.getValueOf("userLastName"), f.getValueOf("userEmail") );
db.User.login(user, user.email);
}
db.User.login(user, user.email);
}
WaitingListService.registerToWl(app.user,group,form.getValueOf("msg")); WaitingListService.registerToWl(app.user,group,form.getValueOf("msg"));
throw Ok("/group/" + group.id,t._("Your subscription to the waiting list has been recorded. You will receive an e-mail as soon as your request is processed.") ); throw Ok("/group/" + group.id,t._("Your subscription to the waiting list has been recorded. You will receive an e-mail as soon as your request is processed.") );
}catch(e:tink.core.Error){ }catch(e:tink.core.Error){
throw Error("/group/list/" + group.id,e.message); throw Error("/group/list/" + group.id,e.message);
} }
} }
view.title = t._("Subscription to \"::groupeName::\" waiting list", {groupeName:group.name}); view.title = t._("Subscription to \"::groupeName::\" waiting list", {groupeName:group.name});
view.form = form;
view.form = form;
} }
/** /**
@ -82,27 +82,27 @@ class Group extends controller.Controller
function doListCancel(group:db.Amap){ function doListCancel(group:db.Amap){
try{ try{
WaitingListService.removeFromWl(app.user,group); WaitingListService.removeFromWl(app.user,group);
}catch(e:tink.core.Error){
}catch(e:tink.core.Error){
throw Error("/group/" + group.id,e.message); throw Error("/group/" + group.id,e.message);
} }
throw Ok("/group/" + group.id,t._("You've been removed from the waiting list")); throw Ok("/group/" + group.id,t._("You've been removed from the waiting list"));
} }
/** /**
* Register direclty in an open group * Register direclty in an open group
*
*
* the user can be logged or not ! * the user can be logged or not !
@tpl('form.mtt') @tpl('form.mtt')
function doRegister(group:db.Amap){ function doRegister(group:db.Amap){
if (group.regOption != db.Amap.RegOption.Open) throw Redirect("/group/" + group.id); if (group.regOption != db.Amap.RegOption.Open) throw Redirect("/group/" + group.id);
if (app.user != null){
if ( db.UserAmap.manager.select($amapId == group.id && $user == app.user) != null) throw Error("/group/" + group.id, t._("You are already member of this group."));
if (app.user != null){
if ( db.UserAmap.manager.select($amapId == group.id && $user == app.user) != null) throw Error("/group/" + group.id, t._("You are already member of this group."));
} }
var form = new sugoi.form.Form("reg");
var form = new sugoi.form.Form("reg");
form.submitButtonLabel = t._("Join the group"); form.submitButtonLabel = t._("Join the group");
form.addElement(new sugoi.form.elements.Html("html",t._("Confirm your subscription to \"::groupName::\"", {groupName:group.name}))); form.addElement(new sugoi.form.elements.Html("html",t._("Confirm your subscription to \"::groupName::\"", {groupName:group.name})));
if (app.user == null){ if (app.user == null){
@ -110,15 +110,15 @@ class Group extends controller.Controller
form.addElement(new StringInput("userLastName", t._("Your lastname"), "", true)); form.addElement(new StringInput("userLastName", t._("Your lastname"), "", true));
var em = new StringInput("userEmail", t._("Your e-mail"), "", true); var em = new StringInput("userEmail", t._("Your e-mail"), "", true);
em.addValidator(new EmailValidator()); em.addValidator(new EmailValidator());
form.addElement(em);
form.addElement(new StringInput("address", t._("Address"), "", true));
form.addElement(new StringInput("zipCode", t._("Zip code"), "", true));
form.addElement(new StringInput("city", t._("City"), "", true));
form.addElement(new StringInput("phone", t._("Phone"), "", true));
form.addElement(em);
form.addElement(new StringInput("address", t._("Address"), "", true));
form.addElement(new StringInput("zipCode", t._("Zip code"), "", true));
form.addElement(new StringInput("city", t._("City"), "", true));
form.addElement(new StringInput("phone", t._("Phone"), "", true));
} }
if (form.isValid()){ if (form.isValid()){
if (app.user == null){ if (app.user == null){
var f = form; var f = form;
var user = new db.User(); var user = new db.User();
@ -129,92 +129,92 @@ class Group extends controller.Controller
user.zipCode = f.getValueOf("zipCode"); user.zipCode = f.getValueOf("zipCode");
user.city = f.getValueOf("city"); user.city = f.getValueOf("city");
user.phone = f.getValueOf("phone"); user.phone = f.getValueOf("phone");
if ( db.User.getSameEmail(user.email).length > 0 ) { if ( db.User.getSameEmail(user.email).length > 0 ) {
throw Ok("/user/login",t._("You already subscribed to Cagette.net, please log in on this page")); throw Ok("/user/login",t._("You already subscribed to Cagette.net, please log in on this page"));
} }
user.insert();
user.insert();
app.session.setUser(user); app.session.setUser(user);
}
}
var w = new db.UserAmap(); var w = new db.UserAmap();
w.user = app.user; w.user = app.user;
w.amap = group; w.amap = group;
w.insert(); w.insert();
throw Ok("/user/choose", t._("Your subscription has been taken into account")); throw Ok("/user/choose", t._("Your subscription has been taken into account"));
} }
view.title = t._("Subscription to \"::groupName::\"", {groupName:group.name}); view.title = t._("Subscription to \"::groupName::\"", {groupName:group.name});
view.form = form; view.form = form;
}*/ }*/
/** /**
* create a new group * create a new group
*/ */
@tpl("form.mtt") @tpl("form.mtt")
function doCreate() { function doCreate() {
view.title = t._("Create a new Cagette Group"); view.title = t._("Create a new Cagette Group");
var f = new sugoi.form.Form("c"); var f = new sugoi.form.Form("c");
f.addElement(new StringInput("name", t._("Name of your group"), "", true)); f.addElement(new StringInput("name", t._("Name of your group"), "", true));
//group type //group type
var data = [ var data = [
{label:t._("CSA"),value:"0"}, {label:t._("CSA"),value:"0"},
{label:t._("Grouped orders"),value:"1"}, {label:t._("Grouped orders"),value:"1"},
{label:t._("Farmers collective"),value:"2"}, {label:t._("Farmers collective"),value:"2"},
{label:t._("Farm shop"),value:"3"}, {label:t._("Farm shop"),value:"3"},
];
];
var gt = new sugoi.form.elements.RadioGroup("type", t._("Group type"), data ,"1","1",true,true,true); var gt = new sugoi.form.elements.RadioGroup("type", t._("Group type"), data ,"1","1",true,true,true);
f.addElement(gt); f.addElement(gt);
if (f.checkToken()) { if (f.checkToken()) {
var user = app.user; var user = app.user;
var g = new db.Amap(); var g = new db.Amap();
g.name = f.getValueOf("name"); g.name = f.getValueOf("name");
g.contact = user; g.contact = user;
var type:db.Amap.GroupType = Type.createEnumIndex(db.Amap.GroupType, Std.parseInt(f.getValueOf("type")) ); var type:db.Amap.GroupType = Type.createEnumIndex(db.Amap.GroupType, Std.parseInt(f.getValueOf("type")) );
switch(type){ switch(type){
case null :
case null :
throw "unknown group type"; throw "unknown group type";
case db.Amap.GroupType.Amap :
case db.Amap.GroupType.Amap :
g.flags.set(db.Amap.AmapFlags.HasMembership); g.flags.set(db.Amap.AmapFlags.HasMembership);
g.regOption = db.Amap.RegOption.WaitingList; g.regOption = db.Amap.RegOption.WaitingList;
case db.Amap.GroupType.GroupedOrders : case db.Amap.GroupType.GroupedOrders :
g.flags.set(db.Amap.AmapFlags.ShopMode); g.flags.set(db.Amap.AmapFlags.ShopMode);
g.flags.set(db.Amap.AmapFlags.HasMembership); g.flags.set(db.Amap.AmapFlags.HasMembership);
g.regOption = db.Amap.RegOption.WaitingList; g.regOption = db.Amap.RegOption.WaitingList;
case db.Amap.GroupType.ProducerDrive :
case db.Amap.GroupType.ProducerDrive :
g.flags.set(db.Amap.AmapFlags.ShopMode); g.flags.set(db.Amap.AmapFlags.ShopMode);
g.regOption = db.Amap.RegOption.Open; g.regOption = db.Amap.RegOption.Open;
g.flags.set(db.Amap.AmapFlags.PhoneRequired); g.flags.set(db.Amap.AmapFlags.PhoneRequired);
case db.Amap.GroupType.FarmShop :
case db.Amap.GroupType.FarmShop :
g.flags.set(db.Amap.AmapFlags.ShopMode); g.flags.set(db.Amap.AmapFlags.ShopMode);
g.regOption = db.Amap.RegOption.Open; g.regOption = db.Amap.RegOption.Open;
g.flags.set(db.Amap.AmapFlags.PhoneRequired); g.flags.set(db.Amap.AmapFlags.PhoneRequired);
} }
g.groupType = type; g.groupType = type;
g.insert(); g.insert();
var ua = new db.UserAmap(); var ua = new db.UserAmap();
ua.user = user; ua.user = user;
ua.amap = g; ua.amap = g;
ua.rights = [db.UserAmap.Right.GroupAdmin,db.UserAmap.Right.Membership,db.UserAmap.Right.Messages,db.UserAmap.Right.ContractAdmin(null)]; ua.rights = [db.UserAmap.Right.GroupAdmin,db.UserAmap.Right.Membership,db.UserAmap.Right.Messages,db.UserAmap.Right.ContractAdmin(null)];
ua.insert(); ua.insert();
//example datas //example datas
var place = new db.Place(); var place = new db.Place();
place.name = t._("Market square"); place.name = t._("Market square");
@ -222,7 +222,7 @@ class Group extends controller.Controller
place.city = "St Martin de la Cagette"; place.city = "St Martin de la Cagette";
place.amap = g; place.amap = g;
place.insert(); place.insert();
//contrat AMAP //contrat AMAP
var vendor = new db.Vendor(); var vendor = new db.Vendor();
vendor.amap = g; vendor.amap = g;
@ -230,8 +230,8 @@ class Group extends controller.Controller
vendor.zipCode = "000"; vendor.zipCode = "000";
vendor.city = "Langon"; vendor.city = "Langon";
vendor.email = "jean@cagette.net"; vendor.email = "jean@cagette.net";
vendor.insert();
vendor.insert();
if (type == Amap){ if (type == Amap){
var contract = new db.Contract(); var contract = new db.Contract();
contract.name = t._("CSA contract Vegetables - Example"); contract.name = t._("CSA contract Vegetables - Example");
@ -244,32 +244,32 @@ class Group extends controller.Controller
contract.contact = user; contract.contact = user;
contract.distributorNum = 2; contract.distributorNum = 2;
contract.insert(); contract.insert();
var p = new db.Product(); var p = new db.Product();
p.name = t._("Big basket of vegetables"); p.name = t._("Big basket of vegetables");
p.price = 15; p.price = 15;
p.organic = true; p.organic = true;
p.contract = contract; p.contract = contract;
p.insert(); p.insert();
var p = new db.Product(); var p = new db.Product();
p.name = t._("Small basket of vegetables"); p.name = t._("Small basket of vegetables");
p.price = 10; p.price = 10;
p.organic = true; p.organic = true;
p.contract = contract; p.contract = contract;
p.insert(); p.insert();
OrderService.make(user, 1, p, null, true); OrderService.make(user, 1, p, null, true);
var d = new db.Distribution(); var d = new db.Distribution();
d.contract = contract; d.contract = contract;
d.date = DateTools.delta(Date.now(), 1000.0 * 60 * 60 * 24 * 14); d.date = DateTools.delta(Date.now(), 1000.0 * 60 * 60 * 24 * 14);
d.end = DateTools.delta(d.date, 1000.0 * 60 * 90); d.end = DateTools.delta(d.date, 1000.0 * 60 * 90);
d.place = place; d.place = place;
d.insert(); d.insert();
} }
//contrat variable //contrat variable
var vendor = new db.Vendor(); var vendor = new db.Vendor();
vendor.amap = g; vendor.amap = g;
@ -277,8 +277,8 @@ class Group extends controller.Controller
vendor.zipCode = "000"; vendor.zipCode = "000";
vendor.city = t._("Bazas"); vendor.city = t._("Bazas");
vendor.email = "galinette@cagette.net"; vendor.email = "galinette@cagette.net";
vendor.insert();
vendor.insert();
var contract = new db.Contract(); var contract = new db.Contract();
contract.name = t._("Chicken Contract - Example"); contract.name = t._("Chicken Contract - Example");
contract.description = t._("Example of contract with variable orders. It is allowed to order something else at every delivery."); contract.description = t._("Example of contract with variable orders. It is allowed to order something else at every delivery.");
@ -291,7 +291,7 @@ class Group extends controller.Controller
contract.distributorNum = 2; contract.distributorNum = 2;
contract.flags.set(db.Contract.ContractFlags.UsersCanOrder); contract.flags.set(db.Contract.ContractFlags.UsersCanOrder);
contract.insert(); contract.insert();
var egg = new db.Product(); var egg = new db.Product();
egg.name = t._("12 eggs"); egg.name = t._("12 eggs");
egg.price = 5; egg.price = 5;
@ -299,7 +299,7 @@ class Group extends controller.Controller
egg.organic = true; egg.organic = true;
egg.contract = contract; egg.contract = contract;
egg.insert(); egg.insert();
var p = new db.Product(); var p = new db.Product();
p.name = t._("Chicken"); p.name = t._("Chicken");
//p.type = 2; //p.type = 2;
@ -307,7 +307,7 @@ class Group extends controller.Controller
p.organic = true; p.organic = true;
p.contract = contract; p.contract = contract;
p.insert(); p.insert();
var d = new db.Distribution(); var d = new db.Distribution();
d.contract = contract; d.contract = contract;
d.orderStartDate = Date.now(); d.orderStartDate = Date.now();
@ -316,36 +316,36 @@ class Group extends controller.Controller
d.end = DateTools.delta(d.date, 1000.0 * 60 * 90); d.end = DateTools.delta(d.date, 1000.0 * 60 * 90);
d.place = place; d.place = place;
d.insert(); d.insert();
OrderService.make(user, 2, egg, d.id); OrderService.make(user, 2, egg, d.id);
OrderService.make(user, 1, p, d.id); OrderService.make(user, 1, p, d.id);
App.current.session.data.amapId = g.id; App.current.session.data.amapId = g.id;
app.session.data.newGroup = true; app.session.data.newGroup = true;
throw Redirect("/"); throw Redirect("/");
} }
view.form= f; view.form= f;
} }
/** /**
Displays a google map in a popup Displays a google map in a popup
**/ **/
@tpl('group/place.mtt') @tpl('group/place.mtt')
public function doPlace(place:db.Place){ public function doPlace(place:db.Place){
view.place = place; view.place = place;
//build adress for google maps //build adress for google maps
var addr = ""; var addr = "";
if (place.address1 != null) addr += place.address1; if (place.address1 != null) addr += place.address1;
if (place.address2 != null) addr += ", " + place.address2; if (place.address2 != null) addr += ", " + place.address2;
if (place.zipCode != null) addr += " " + place.zipCode; if (place.zipCode != null) addr += " " + place.zipCode;
if (place.city != null) addr += " " + place.city; if (place.city != null) addr += " " + place.city;
view.addr = view.escapeJS(addr); view.addr = view.escapeJS(addr);
} }
/** /**
* Groups map * Groups map
*/ */
@ -353,16 +353,16 @@ class Group extends controller.Controller
public function doMap(?args:{?lat:Float,?lng:Float,?address:String}){ public function doMap(?args:{?lat:Float,?lng:Float,?address:String}){
view.container = "container-fluid"; view.container = "container-fluid";
//if no param is sent, focus on Paris //if no param is sent, focus on Paris
if (args == null || (args.address == null && args.lat == null && args.lng == null)){ if (args == null || (args.address == null && args.lat == null && args.lng == null)){
args = {lat:48.855675, lng:2.3472365}; args = {lat:48.855675, lng:2.3472365};
} }
view.lat = args.lat; view.lat = args.lat;
view.lng = args.lng; view.lng = args.lng;
view.address = args.address;
view.address = args.address;
} }
} }

97
src/controller/Main.hx

@ -9,10 +9,10 @@ import Common;
import tools.ArrayTool; import tools.ArrayTool;
class Main extends Controller { class Main extends Controller {
/** /**
* public pages
* public pages
*/ */
function doGroup(d:haxe.web.Dispatch){ function doGroup(d:haxe.web.Dispatch){
d.dispatch(new controller.Group()); d.dispatch(new controller.Group());
@ -24,23 +24,24 @@ class Main extends Controller {
@tpl("home.mtt") @tpl("home.mtt")
function doDefault() { function doDefault() {
view.category = 'home'; view.category = 'home';
var group = app.getCurrentGroup();
if ( app.user!=null && group == null) {
var group = app.getCurrentGroup();
if ( app.user!=null && group == null) {
throw Redirect("/user/choose"); throw Redirect("/user/choose");
}else if (app.user == null && (group==null || group.regOption!=db.Amap.RegOption.Open) ) { }else if (app.user == null && (group==null || group.regOption!=db.Amap.RegOption.Open) ) {
throw Redirect("/user/login");
//throw Redirect("/user/login");
throw Redirect("/group/1");
} }
view.amap = group; view.amap = group;
//contract with open orders //contract with open orders
var openContracts = Lambda.filter(group.getActiveContracts(), function(c) return c.isUserOrderAvailable()); var openContracts = Lambda.filter(group.getActiveContracts(), function(c) return c.isUserOrderAvailable());
view.openContracts = openContracts; view.openContracts = openContracts;
//register to become "distributor" //register to become "distributor"
view.contractsWithDistributors = app.user==null ? [] : Lambda.filter(app.user.amap.getActiveContracts(), function(c) return c.distributorNum > 0); view.contractsWithDistributors = app.user==null ? [] : Lambda.filter(app.user.amap.getActiveContracts(), function(c) return c.distributorNum > 0);
//freshly created group //freshly created group
view.newGroup = app.session.data.newGroup == true; view.newGroup = app.session.data.newGroup == true;
@ -50,12 +51,12 @@ class Main extends Controller {
var distribs = MultiDistrib.getFromTimeRange(group,now,in3Month); var distribs = MultiDistrib.getFromTimeRange(group,now,in3Month);
view.distribs = distribs; view.distribs = distribs;
//view functions //view functions
view.getWhosTurn = function(orderId:Int, distrib:Distribution) { view.getWhosTurn = function(orderId:Int, distrib:Distribution) {
return db.UserContract.manager.get(orderId, false).getWhosTurn(distrib); return db.UserContract.manager.get(orderId, false).getWhosTurn(distrib);
} }
//event for additionnal blocks on home page //event for additionnal blocks on home page
var e = Blocks([], "home"); var e = Blocks([], "home");
app.event(e); app.event(e);
@ -67,21 +68,21 @@ class Main extends Controller {
} }
} }
//login and stuff //login and stuff
function doUser(d:Dispatch) { function doUser(d:Dispatch) {
d.dispatch(new controller.User()); d.dispatch(new controller.User());
} }
function doCron(d:Dispatch) { function doCron(d:Dispatch) {
d.dispatch(new controller.Cron()); d.dispatch(new controller.Cron());
} }
/** /**
* JSON REST API Entry point * JSON REST API Entry point
*/ */
function doApi(d:Dispatch) { function doApi(d:Dispatch) {
try { try {
d.dispatch(new controller.Api()); d.dispatch(new controller.Api());
@ -91,38 +92,38 @@ class Main extends Controller {
//manage tink Errors (service errors) //manage tink Errors (service errors)
sugoi.Web.setReturnCode(e.code); sugoi.Web.setReturnCode(e.code);
Sys.print(Json.stringify( {error:{code:e.code,message:e.message,stack:e.exceptionStack}} )); Sys.print(Json.stringify( {error:{code:e.code,message:e.message,stack:e.exceptionStack}} ));
}catch (e:Dynamic){ }catch (e:Dynamic){
//manage other errors
sugoi.Web.setReturnCode(500);
//manage other errors
sugoi.Web.setReturnCode(500);
var stack = if ( App.config.DEBUG ) haxe.CallStack.toString(haxe.CallStack.exceptionStack()) else ""; var stack = if ( App.config.DEBUG ) haxe.CallStack.toString(haxe.CallStack.exceptionStack()) else "";
App.current.logError(e, stack); App.current.logError(e, stack);
Sys.print(Json.stringify( {error:{code:500,message : Std.string(e), stack:stack }} )); Sys.print(Json.stringify( {error:{code:500,message : Std.string(e), stack:stack }} ));
} }
} }
@tpl("cssDemo.mtt") @tpl("cssDemo.mtt")
function doCssdemo() { function doCssdemo() {
view.category = 'home'; view.category = 'home';
} }
@tpl("form.mtt") @tpl("form.mtt")
function doInstall(d:Dispatch) { function doInstall(d:Dispatch) {
d.dispatch(new controller.Install()); d.dispatch(new controller.Install());
} }
function doP(d:Dispatch) { function doP(d:Dispatch) {
/* /*
* Invalid array access * Invalid array access
Stack (ADMIN|DEBUG) Stack (ADMIN|DEBUG)
Called from C:\HaxeToolkit\haxe\std/haxe/web/Dispatch.hx line 463 Called from C:\HaxeToolkit\haxe\std/haxe/web/Dispatch.hx line 463
Called from controller/Main.hx line 117 Called from controller/Main.hx line 117
*
*
var plugin = d.parts.shift(); var plugin = d.parts.shift();
for ( p in App.plugins) { for ( p in App.plugins) {
var n = Type.getClassName(Type.getClass(p)).toLowerCase(); var n = Type.getClassName(Type.getClass(p)).toLowerCase();
@ -132,26 +133,26 @@ Called from controller/Main.hx line 117
return; return;
} }
} }
throw Error("/","Plugin '"+plugin+"' introuvable."); throw Error("/","Plugin '"+plugin+"' introuvable.");
*/ */
d.dispatch(new controller.Plugin()); d.dispatch(new controller.Plugin());
} }
@logged @logged
function doMember(d:Dispatch) { function doMember(d:Dispatch) {
view.category = 'members'; view.category = 'members';
d.dispatch(new controller.Member()); d.dispatch(new controller.Member());
} }
@logged @logged
function doStats(d:Dispatch) { function doStats(d:Dispatch) {
view.category = 'stats'; view.category = 'stats';
d.dispatch(new Stats()); d.dispatch(new Stats());
} }
@logged @logged
function doAccount(d:Dispatch) { function doAccount(d:Dispatch) {
view.category = 'account'; view.category = 'account';
@ -163,31 +164,31 @@ Called from controller/Main.hx line 117
view.category = 'contractadmin'; view.category = 'contractadmin';
d.dispatch(new controller.Vendor()); d.dispatch(new controller.Vendor());
} }
@logged @logged
function doPlace(d:Dispatch) { function doPlace(d:Dispatch) {
view.category = 'contractadmin'; view.category = 'contractadmin';
d.dispatch(new controller.Place()); d.dispatch(new controller.Place());
} }
@logged @logged
function doTransaction(d:Dispatch) { function doTransaction(d:Dispatch) {
view.category = 'members'; view.category = 'members';
d.dispatch(new controller.Transaction()); d.dispatch(new controller.Transaction());
} }
@logged @logged
function doDistribution(d:Dispatch) { function doDistribution(d:Dispatch) {
view.category = 'contractadmin'; view.category = 'contractadmin';
d.dispatch(new controller.Distribution()); d.dispatch(new controller.Distribution());
} }
@logged @logged
function doMembership(d:Dispatch) { function doMembership(d:Dispatch) {
view.category = 'members'; view.category = 'members';
d.dispatch(new controller.Membership()); d.dispatch(new controller.Membership());
} }
function doShop(d:Dispatch) { function doShop(d:Dispatch) {
view.category = 'shop'; view.category = 'shop';
d.dispatch(new controller.Shop()); d.dispatch(new controller.Shop());
@ -199,63 +200,63 @@ Called from controller/Main.hx line 117
view.place = place; view.place = place;
view.date = date; view.date = date;
} }
@logged @logged
function doProduct(d:Dispatch) { function doProduct(d:Dispatch) {
view.category = 'contractadmin'; view.category = 'contractadmin';
d.dispatch(new controller.Product()); d.dispatch(new controller.Product());
} }
@logged @logged
function doAmap(d:Dispatch) { function doAmap(d:Dispatch) {
view.category = 'amap'; view.category = 'amap';
d.dispatch(new controller.Amap()); d.dispatch(new controller.Amap());
} }
@logged @logged
function doContract(d:Dispatch) { function doContract(d:Dispatch) {
view.category = 'contract'; view.category = 'contract';
d.dispatch(new Contract()); d.dispatch(new Contract());
} }
@logged @logged
function doContractAdmin(d:Dispatch) { function doContractAdmin(d:Dispatch) {
view.category = 'contractadmin'; view.category = 'contractadmin';
d.dispatch(new ContractAdmin()); d.dispatch(new ContractAdmin());
} }
@logged @logged
function doMessages(d:Dispatch) { function doMessages(d:Dispatch) {
view.category = 'messages'; view.category = 'messages';
d.dispatch(new Messages()); d.dispatch(new Messages());
} }
@logged @logged
function doAmapadmin(d:Dispatch) { function doAmapadmin(d:Dispatch) {
view.category = 'amapadmin'; view.category = 'amapadmin';
d.dispatch(new AmapAdmin()); d.dispatch(new AmapAdmin());
} }
@logged @logged
function doValidate(date:Date, place:db.Place, user:db.User, d:haxe.web.Dispatch){ function doValidate(date:Date, place:db.Place, user:db.User, d:haxe.web.Dispatch){
var v = new controller.Validate(); var v = new controller.Validate();
v.date = date; v.date = date;
v.place = place; v.place = place;
v.user = user;
v.user = user;
d.dispatch(v); d.dispatch(v);
} }
@admin @admin
function doAdmin(d:Dispatch) { function doAdmin(d:Dispatch) {
d.dispatch(new controller.admin.Admin()); d.dispatch(new controller.admin.Admin());
} }
@admin @admin
function doDb(d:Dispatch) { function doDb(d:Dispatch) {
d.parts = []; //disable haxe.web.Dispatch d.parts = []; //disable haxe.web.Dispatch
sys.db.Admin.handler(); sys.db.Admin.handler();
} }
} }

12
src/service/WaitingListService.hx

@ -13,6 +13,8 @@ class WaitingListService{
var w = new db.WaitingList(); var w = new db.WaitingList();
w.user = user; w.user = user;
w.group = group; w.group = group;
if (message == null ) message = "";
//message = "souscription = " + message;
w.message = message; w.message = message;
w.insert(); w.insert();
@ -39,7 +41,7 @@ class WaitingListService{
public static function canRegister(user:db.User,group:db.Amap){ public static function canRegister(user:db.User,group:db.Amap){
var t = sugoi.i18n.Locale.texts; var t = sugoi.i18n.Locale.texts;
if ( db.WaitingList.manager.select($amapId == group.id && $user == user) != null) { if ( db.WaitingList.manager.select($amapId == group.id && $user == user) != null) {
throw new Error(t._("You are already in the waiting list of this group")); throw new Error(t._("You are already in the waiting list of this group"));
} }
@ -91,7 +93,7 @@ class WaitingListService{
group group
); );
} }
wl.delete(); wl.delete();
} }
@ -108,9 +110,9 @@ class WaitingListService{
var ua = new db.UserAmap(); var ua = new db.UserAmap();
ua.amap = wl.group; ua.amap = wl.group;
ua.user = wl.user; ua.user = wl.user;
ua.insert();
ua.insert();
} }
wl.delete(); wl.delete();
//email the requester //email the requester
@ -131,7 +133,7 @@ class WaitingListService{
group group
); );
} }
wl.delete(); wl.delete();
} }

1
www/lang/texts_fr.po

@ -14,6 +14,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n > 1;\n" "Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Poedit 2.0.6\n" "X-Generator: Poedit 2.0.6\n"
#: src/payment/Cash.hx:294 #: src/payment/Cash.hx:294
msgid "Cash" msgid "Cash"
msgstr "Espèces / Carte Bancaire" msgstr "Espèces / Carte Bancaire"

Loading…
Cancel
Save