fix agenda file to compile
This commit is contained in:
parent
3bfce72512
commit
e11514b6d5
|
@ -227,7 +227,6 @@ func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http
|
|||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
dis := fmt.Sprint(current_user_claims["first_name"]) + " " + fmt.Sprint(current_user_claims["last_name"])
|
||||
subscriber := r.FormValue("subscriber")
|
||||
data := map[string]any{
|
||||
"subscribed_by": map[string]any{
|
||||
|
@ -333,8 +332,125 @@ func contains(s []*agenda.Subscription, e string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
///////////////////////////Delete subscriber///////////////////////////////
|
||||
///////////////////////////////Update Event/////////////////////////////////////////
|
||||
func (h *ApplicationHandler) AgendaUpdateEvent(w http.ResponseWriter, r *http.Request) {
|
||||
adm := strings.Split(r.URL.Path, "/")
|
||||
eventID := adm[3]
|
||||
request := &agenda.GetEventRequest{
|
||||
Id: eventID,
|
||||
}
|
||||
|
||||
resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if r.Method == "POST" {
|
||||
g := r.Context().Value(identification.GroupKey)
|
||||
if g == nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
group := g.(storage.Group)
|
||||
|
||||
eventForm, err := parseEventsForm(r)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
data, _ := structpb.NewStruct(map[string]any{
|
||||
"address": eventForm.Address,
|
||||
})
|
||||
|
||||
request := &agenda.UpdateEventRequest{
|
||||
Event: &agenda.Event{
|
||||
Namespace: "parcoursmob_dispositifs",
|
||||
Id: eventID,
|
||||
Owners: []string{group.ID},
|
||||
Type: eventForm.Type,
|
||||
Name: eventForm.Name,
|
||||
Description: eventForm.Description,
|
||||
Startdate: timestamppb.New(*eventForm.Startdate),
|
||||
Enddate: timestamppb.New(*eventForm.Enddate),
|
||||
Starttime: eventForm.Starttime,
|
||||
Endtime: eventForm.Endtime,
|
||||
Allday: eventForm.Allday,
|
||||
MaxSubscribers: int64(eventForm.MaxSubscribers),
|
||||
Data: data,
|
||||
Subscriptions: resp.Event.Subscriptions,
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := h.services.GRPC.Agenda.UpdateEvent(context.TODO(), request)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", resp.Event.Id), http.StatusFound)
|
||||
return
|
||||
}
|
||||
h.Renderer.AgendaUpdateEvent(w, r, resp.Event.ToStorageType())
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) AgendaDeleteEvent(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
vars := mux.Vars(r)
|
||||
eventID := vars["eventid"]
|
||||
request := &agenda.GetEventRequest{
|
||||
Id: eventID,
|
||||
}
|
||||
|
||||
resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if r.Method == "POST" {
|
||||
|
||||
request := &agenda.UpdateEventRequest{
|
||||
Event: &agenda.Event{
|
||||
Namespace: resp.Event.Namespace,
|
||||
Id: resp.Event.Id,
|
||||
Owners: resp.Event.Owners,
|
||||
Type: resp.Event.Type,
|
||||
Name: resp.Event.Name,
|
||||
Description: resp.Event.Description,
|
||||
Startdate: resp.Event.Startdate,
|
||||
Enddate: resp.Event.Enddate,
|
||||
Starttime: resp.Event.Starttime,
|
||||
Endtime: resp.Event.Endtime,
|
||||
Allday: resp.Event.Allday,
|
||||
MaxSubscribers: int64(resp.Event.MaxSubscribers),
|
||||
Data: resp.Event.Data,
|
||||
Subscriptions: resp.Event.Subscriptions,
|
||||
Deleted: true,
|
||||
},
|
||||
}
|
||||
|
||||
_, err := h.services.GRPC.Agenda.UpdateEvent(context.TODO(), request)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/app/agenda/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
h.Renderer.AgendaDeleteEvent(w, r, resp.Event.ToStorageType())
|
||||
}
|
||||
|
||||
///////////////////////////Delete subscriber///////////////////////////////
|
||||
func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
eventId := vars["eventid"]
|
||||
|
@ -346,12 +462,6 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
s_b_group_name := ""
|
||||
request := &agenda.GetEventRequest{
|
||||
Id: eventId,
|
||||
///////////////////////////////Update Event/////////////////////////////////////////
|
||||
func (h *ApplicationHandler) AgendaUpdateEvent(w http.ResponseWriter, r *http.Request) {
|
||||
adm := strings.Split(r.URL.Path, "/")
|
||||
eventID := adm[3]
|
||||
request := &agenda.GetEventRequest{
|
||||
Id: eventID,
|
||||
}
|
||||
|
||||
resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request)
|
||||
|
@ -436,50 +546,10 @@ func (h *ApplicationHandler) AgendaUpdateEvent(w http.ResponseWriter, r *http.Re
|
|||
}
|
||||
|
||||
// récupérer l'adresse mail de l'utilisateur qui a créé l'événement
|
||||
mail := s_b_email;
|
||||
mail := s_b_email
|
||||
fmt.Println(mail)
|
||||
|
||||
_, err := h.services.GRPC.Agenda.DeleteSubscription(context.TODO(), request)
|
||||
if r.Method == "POST" {
|
||||
g := r.Context().Value(identification.GroupKey)
|
||||
if g == nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
group := g.(storage.Group)
|
||||
|
||||
eventForm, err := parseEventsForm(r)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
data, _ := structpb.NewStruct(map[string]any{
|
||||
"address": eventForm.Address,
|
||||
})
|
||||
|
||||
request := &agenda.UpdateEventRequest{
|
||||
Event: &agenda.Event{
|
||||
Namespace: "parcoursmob_dispositifs",
|
||||
Id: eventID,
|
||||
Owners: []string{group.ID},
|
||||
Type: eventForm.Type,
|
||||
Name: eventForm.Name,
|
||||
Description: eventForm.Description,
|
||||
Startdate: timestamppb.New(*eventForm.Startdate),
|
||||
Enddate: timestamppb.New(*eventForm.Enddate),
|
||||
Starttime: eventForm.Starttime,
|
||||
Endtime: eventForm.Endtime,
|
||||
Allday: eventForm.Allday,
|
||||
MaxSubscribers: int64(eventForm.MaxSubscribers),
|
||||
Data: data,
|
||||
Subscriptions: resp.Event.Subscriptions,
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := h.services.GRPC.Agenda.UpdateEvent(context.TODO(), request)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
@ -500,25 +570,12 @@ func (h *ApplicationHandler) AgendaUpdateEvent(w http.ResponseWriter, r *http.Re
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
// /////////////////////History Event////////////////////////
|
||||
func (h *ApplicationHandler) AgendaHistoryEvent(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
eventId := vars["eventid"]
|
||||
request := &agenda.GetEventRequest{
|
||||
Id: eventId,
|
||||
http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", resp.Event.Id), http.StatusFound)
|
||||
return
|
||||
}
|
||||
h.Renderer.AgendaUpdateEvent(w, r, resp.Event.ToStorageType())
|
||||
}
|
||||
|
||||
func (h *ApplicationHandler) AgendaDeleteEvent(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
vars := mux.Vars(r)
|
||||
eventID := vars["eventid"]
|
||||
request := &agenda.GetEventRequest{
|
||||
Id: eventID,
|
||||
}
|
||||
|
||||
resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request)
|
||||
|
@ -590,55 +647,5 @@ func (h *ApplicationHandler) AgendaDeleteEvent(w http.ResponseWriter, r *http.Re
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
h.Renderer.AgendaHistoryEvent(w, r, resp.Event.ToStorageType(), groupresp.Group.ToStorageType(), subscribers, accounts)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
if r.Method == "POST" {
|
||||
|
||||
request := &agenda.UpdateEventRequest{
|
||||
Event: &agenda.Event{
|
||||
Namespace: resp.Event.Namespace,
|
||||
Id: resp.Event.Id,
|
||||
Owners: resp.Event.Owners,
|
||||
Type: resp.Event.Type,
|
||||
Name: resp.Event.Name,
|
||||
Description: resp.Event.Description,
|
||||
Startdate: resp.Event.Startdate,
|
||||
Enddate: resp.Event.Enddate,
|
||||
Starttime: resp.Event.Starttime,
|
||||
Endtime: resp.Event.Endtime,
|
||||
Allday: resp.Event.Allday,
|
||||
MaxSubscribers: int64(resp.Event.MaxSubscribers),
|
||||
Data: resp.Event.Data,
|
||||
Subscriptions: resp.Event.Subscriptions,
|
||||
Deleted: true,
|
||||
},
|
||||
}
|
||||
|
||||
_, err := h.services.GRPC.Agenda.UpdateEvent(context.TODO(), request)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/app/agenda/", http.StatusFound)
|
||||
return
|
||||
}
|
||||
h.Renderer.AgendaDeleteEvent(w, r, resp.Event.ToStorageType())
|
||||
}
|
||||
|
||||
// func contains[V string](s []V, e V) bool {
|
||||
// for _, a := range s {
|
||||
// if a == e {
|
||||
// return true
|
||||
// }
|
||||
// }
|
||||
// return false
|
||||
// }
|
||||
|
||||
//test
|
||||
|
|
Loading…
Reference in New Issue