merge with main

This commit is contained in:
2025-02-28 18:05:34 +01:00
9 changed files with 751 additions and 45 deletions

View File

@@ -255,7 +255,8 @@ func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWrite
}
data := map[string]any{
"group": groupresp.Group.ToStorageType().Data["name"],
"group": groupresp.Group.ToStorageType().Data["name"],
"baseUrl": h.config.GetString("base_url"),
}
if err := h.emailing.Send("onboarding.existing_administrator", r.FormValue("username"), data); err != nil {
@@ -278,11 +279,16 @@ func (h *ApplicationHandler) AdministrationGroupInviteAdmin(w http.ResponseWrite
}
key := base64.RawURLEncoding.EncodeToString(b)
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
if err := h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour); err != nil { // 1 week TTL
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
data := map[string]any{
"group": groupresp.Group.ToStorageType().Data["name"],
"key": key,
"group": groupresp.Group.ToStorageType().Data["name"],
"key": key,
"baseUrl": h.config.GetString("base_url"),
}
if err := h.emailing.Send("onboarding.new_administrator", r.FormValue("username"), data); err != nil {
@@ -322,7 +328,8 @@ func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWrit
},
)
data := map[string]any{
"group": group.Data["name"],
"group": group.Data["name"],
"baseUrl": h.config.GetString("base_url"),
}
if err := h.emailing.Send("onboarding.existing_member", r.FormValue("username"), data); err != nil {
@@ -346,8 +353,9 @@ func (h *ApplicationHandler) AdministrationGroupInviteMember(w http.ResponseWrit
h.cache.PutWithTTL("onboarding/"+key, onboarding, 168*time.Hour) // 1 week TTL
data := map[string]any{
"group": group.Data["name"],
"key": key,
"group": group.Data["name"],
"key": key,
"baseUrl": h.config.GetString("base_url"),
}
if err := h.emailing.Send("onboarding.new_member", r.FormValue("username"), data); err != nil {

View File

@@ -2,6 +2,7 @@ package application
import (
"context"
"fmt"
"net/http"
"sort"
@@ -18,7 +19,6 @@ import (
)
func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
g := r.Context().Value(identification.GroupKey)
if g == nil {
w.WriteHeader(http.StatusBadRequest)
@@ -38,7 +38,7 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
return
}
var accounts = []any{}
accounts := []any{}
// We only display the 10 last here
count := len(resp.Accounts)
@@ -49,6 +49,7 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
for _, account := range resp.Accounts[min:] {
if filterAccount(r, account) {
fmt.Println(account)
a := account.ToStorageType()
accounts = append([]any{a}, accounts...)
}
@@ -91,5 +92,4 @@ func (h *ApplicationHandler) Dashboard(w http.ResponseWriter, r *http.Request) {
}
h.Renderer.Dashboard(w, r, accounts, count, count_members, events, bookings)
}

View File

@@ -506,6 +506,24 @@ func (h ApplicationHandler) VehiclesFleetMakeUnavailable(w http.ResponseWriter,
http.Redirect(w, r, fmt.Sprintf("/app/vehicles-management/fleet/%s", vehicleid), http.StatusFound)
}
func (h *ApplicationHandler) DeleteBooking(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
bookingid := vars["bookingid"]
request := &fleets.DeleteBookingRequest{
Id: bookingid,
}
_, err := h.services.GRPC.Fleets.DeleteBooking(context.TODO(), request)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
http.Redirect(w, r, "/app/vehicles-management/bookings/", http.StatusSeeOther)
}
func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
bookingid := vars["bookingid"]
@@ -520,9 +538,12 @@ func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Req
w.WriteHeader(http.StatusInternalServerError)
return
}
now := time.Now()
date := now.Format("2006-01-02")
// now := time.Now()
// date := now.Format("2006-01-02")
date := "1970-01-01"
unavailableto, _ := time.Parse("2006-01-02", date)
unavailablefrom := unavailableto
current_group, err := h.currentGroup(r)
if err != nil {
@@ -587,7 +608,7 @@ func (h *ApplicationHandler) UnbookingVehicle(w http.ResponseWriter, r *http.Req
Driver: resp.Booking.Driver,
Startdate: resp.Booking.Startdate,
Enddate: resp.Booking.Enddate,
Unavailablefrom: resp.Booking.Unavailablefrom,
Unavailablefrom: timestamppb.New(unavailablefrom),
Unavailableto: timestamppb.New(unavailableto),
Data: datapb,
},

View File

@@ -143,7 +143,10 @@ func (h *ExportsHandler) generateExcel(events []agendastorage.Event, groups map[
f.SetCellValue("Sheet1", "F1", "Numéro allocataire / Pole emploi")
f.SetCellValue("Sheet1", "G1", "Prescipteur")
f.SetCellValue("Sheet1", "H1", "Prescipteur Nom")
f.SetCellValue("Sheet1", "I1", "Gestionnaire événement")
f.SetCellValue("Sheet1", "I1", "Prescipteur Email")
f.SetCellValue("Sheet1", "J1", "Gestionnaire événement")
// f.SetCellValue("Sheet1", "I1", "Prescripteur téléphone")
i := 2
for _, e := range events {
if len(e.Owners) == 0 {
@@ -151,24 +154,27 @@ func (h *ExportsHandler) generateExcel(events []agendastorage.Event, groups map[
}
admin := groups[e.Owners[0]]
subscribedbygroup := ""
subscribedbyuser := ""
if v, ok := e.Data["subscribed_by"].(map[string]any); ok {
if v2, ok := v["group"].(map[string]any); ok {
if v3, ok := v2["id"].(string); ok {
subscribedbygroup = v3
}
}
if v4, ok := v["user"].(map[string]any); ok {
if v5, ok := v4["display_name"].(string); ok {
subscribedbyuser = v5
}
}
}
for _, s := range e.Subscriptions {
subscribedbygroup := ""
subscribedbyuser := ""
subscribedbyemail := ""
if v, ok := s.Data["subscribed_by"].(map[string]any); ok {
if v2, ok := v["group"].(map[string]any); ok {
if v3, ok := v2["name"].(string); ok {
subscribedbygroup = v3
}
}
if v4, ok := v["user"].(map[string]any); ok {
if v5, ok := v4["display_name"].(string); ok {
subscribedbyuser = v5
}
if v6, ok := v4["email"].(string); ok {
subscribedbyemail = v6
}
}
}
beneficiary := beneficiaries_map[s.Subscriber]
@@ -178,9 +184,10 @@ func (h *ExportsHandler) generateExcel(events []agendastorage.Event, groups map[
f.SetCellValue("Sheet1", fmt.Sprintf("D%d", i), beneficiary.Data["last_name"])
f.SetCellValue("Sheet1", fmt.Sprintf("E%d", i), beneficiary.Data["first_name"])
f.SetCellValue("Sheet1", fmt.Sprintf("F%d", i), beneficiary.Data["file_number"])
f.SetCellValue("Sheet1", fmt.Sprintf("G%d", i), groups[subscribedbygroup].Data["name"])
f.SetCellValue("Sheet1", fmt.Sprintf("G%d", i), subscribedbygroup)
f.SetCellValue("Sheet1", fmt.Sprintf("H%d", i), subscribedbyuser)
f.SetCellValue("Sheet1", fmt.Sprintf("I%d", i), admin.Data["name"])
f.SetCellValue("Sheet1", fmt.Sprintf("I%d", i), subscribedbyemail)
f.SetCellValue("Sheet1", fmt.Sprintf("J%d", i), admin.Data["name"])
i = i + 1
}

View File

@@ -93,8 +93,10 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
f.SetCellValue("Sheet1", "H1", "Fin de mise à disposition")
f.SetCellValue("Sheet1", "I1", "Début indisponibilité")
f.SetCellValue("Sheet1", "J1", "Fin indisponibilité")
f.SetCellValue("Sheet1", "K1", "Retrait par le gestionnaire")
f.SetCellValue("Sheet1", "L1", "Commentaire")
f.SetCellValue("Sheet1", "K1", "Véhicule retiré")
f.SetCellValue("Sheet1", "L1", "Commentaire - Retrait véhicule")
f.SetCellValue("Sheet1", "M1", "Réservation supprimée")
f.SetCellValue("Sheet1", "N1", "Motif de la suppression")
i := 2
for _, b := range bookings {
@@ -138,6 +140,14 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
adminunavailability = true
}
deleted := ""
v, ok := b.Data["Deleted"]
fmt.Println(v)
fmt.Println(ok)
if b.Deleted || (ok && v.(bool)) {
deleted = "DELETED"
}
f.SetCellValue("Sheet1", fmt.Sprintf("A%d", i), vehicle.Data["licence_plate"])
f.SetCellValue("Sheet1", fmt.Sprintf("B%d", i), vehicle.Type)
f.SetCellValue("Sheet1", fmt.Sprintf("C%d", i), admin.Data["name"])
@@ -150,6 +160,8 @@ func (h *ExportsHandler) Bookings(w http.ResponseWriter, r *http.Request) {
f.SetCellValue("Sheet1", fmt.Sprintf("J%d", i), b.Unavailableto.Format("2006-01-02"))
f.SetCellValue("Sheet1", fmt.Sprintf("K%d", i), adminunavailability)
f.SetCellValue("Sheet1", fmt.Sprintf("L%d", i), b.Data["comment"])
f.SetCellValue("Sheet1", fmt.Sprintf("M%d", i), deleted)
f.SetCellValue("Sheet1", fmt.Sprintf("N%d", i), b.Data["motif"])
i = i + 1
}