merge with main
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user