Compare commits
	
		
			5 Commits
		
	
	
		
			f698891865
			...
			335656ec75
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 335656ec75 | |
|  | 5d33ba3dcb | |
|  | af9626e2c4 | |
|  | d3df781e33 | |
|  | 57accbddbb | 
|  | @ -7,6 +7,7 @@ import ( | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"sort" | 	"sort" | ||||||
| 	"strconv" | 	"strconv" | ||||||
|  | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	formvalidators "git.coopgo.io/coopgo-apps/parcoursmob/utils/form-validators" | 	formvalidators "git.coopgo.io/coopgo-apps/parcoursmob/utils/form-validators" | ||||||
|  | @ -107,6 +108,7 @@ func (h *ApplicationHandler) AgendaCreateEvent(w http.ResponseWriter, r *http.Re | ||||||
| 				Allday:         eventForm.Allday, | 				Allday:         eventForm.Allday, | ||||||
| 				MaxSubscribers: int64(eventForm.MaxSubscribers), | 				MaxSubscribers: int64(eventForm.MaxSubscribers), | ||||||
| 				Data:           data, | 				Data:           data, | ||||||
|  | 				Deleted:        false, | ||||||
| 			}, | 			}, | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -119,7 +121,7 @@ func (h *ApplicationHandler) AgendaCreateEvent(w http.ResponseWriter, r *http.Re | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", resp.Event.Id), http.StatusFound) | 		http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", resp.Event.Id), http.StatusFound) | ||||||
| 
 | 		return | ||||||
| 	} | 	} | ||||||
| 	h.Renderer.AgendaCreateEvent(w, r) | 	h.Renderer.AgendaCreateEvent(w, r) | ||||||
| } | } | ||||||
|  | @ -225,7 +227,7 @@ func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http | ||||||
| 		w.WriteHeader(http.StatusBadRequest) | 		w.WriteHeader(http.StatusBadRequest) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 	dis := fmt.Sprint(current_user_claims["first_name"]) + " " + fmt.Sprint(current_user_claims["last_name"]) | ||||||
| 	subscriber := r.FormValue("subscriber") | 	subscriber := r.FormValue("subscriber") | ||||||
| 	data := map[string]any{ | 	data := map[string]any{ | ||||||
| 		"subscribed_by": map[string]any{ | 		"subscribed_by": map[string]any{ | ||||||
|  | @ -344,6 +346,12 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r | ||||||
| 	s_b_group_name := "" | 	s_b_group_name := "" | ||||||
| 	request := &agenda.GetEventRequest{ | 	request := &agenda.GetEventRequest{ | ||||||
| 		Id: eventId, | 		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) | 	resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request) | ||||||
|  | @ -432,6 +440,46 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r | ||||||
| 		fmt.Println(mail) | 		fmt.Println(mail) | ||||||
| 
 | 
 | ||||||
| 		_, err := h.services.GRPC.Agenda.DeleteSubscription(context.TODO(), request) | 		_, 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 { | 		if err != nil { | ||||||
| 			fmt.Println(err) | 			fmt.Println(err) | ||||||
|  | @ -459,6 +507,18 @@ func (h *ApplicationHandler) AgendaHistoryEvent(w http.ResponseWriter, r *http.R | ||||||
| 	eventId := vars["eventid"] | 	eventId := vars["eventid"] | ||||||
| 	request := &agenda.GetEventRequest{ | 	request := &agenda.GetEventRequest{ | ||||||
| 		Id: eventId, | 		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) | 	resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request) | ||||||
|  | @ -536,6 +596,42 @@ func (h *ApplicationHandler) AgendaHistoryEvent(w http.ResponseWriter, r *http.R | ||||||
| 
 | 
 | ||||||
| /////////////////////////////////////////////////////////
 | /////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
|  | 	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 {
 | // func contains[V string](s []V, e V) bool {
 | ||||||
| // 	for _, a := range s {
 | // 	for _, a := range s {
 | ||||||
| // 		if a == e {
 | // 		if a == e {
 | ||||||
|  |  | ||||||
|  | @ -76,7 +76,7 @@ func (h *ApplicationHandler) MemberUpdate(w http.ResponseWriter, r *http.Request | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		http.Redirect(w, r, fmt.Sprintf("/app/profile/%s", resp.Account.Id), http.StatusFound) | 		http.Redirect(w, r, fmt.Sprintf("/app/members/%s", resp.Account.Id), http.StatusFound) | ||||||
| 
 | 
 | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -37,7 +37,7 @@ func (h *AuthHandler) Onboarding(w http.ResponseWriter, r *http.Request) { | ||||||
| 		if onboardingmap["admin"].(bool) { | 		if onboardingmap["admin"].(bool) { | ||||||
| 			groups = append(groups, onboardingmap["group"].(string)+":admin") | 			groups = append(groups, onboardingmap["group"].(string)+":admin") | ||||||
| 		} | 		} | ||||||
| 
 | 		display_name := fmt.Sprint(r.FormValue("first_name")) + " " + fmt.Sprint(r.FormValue("last_name")) | ||||||
| 		account := &ma.Account{ | 		account := &ma.Account{ | ||||||
| 			Authentication: ma.AccountAuth{ | 			Authentication: ma.AccountAuth{ | ||||||
| 				Local: ma.LocalAuth{ | 				Local: ma.LocalAuth{ | ||||||
|  | @ -46,7 +46,9 @@ func (h *AuthHandler) Onboarding(w http.ResponseWriter, r *http.Request) { | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			Namespace: "parcoursmob", | 			Namespace: "parcoursmob", | ||||||
|  | 
 | ||||||
| 			Data: map[string]any{ | 			Data: map[string]any{ | ||||||
|  | 				"display_name": display_name, | ||||||
| 				"first_name":   r.FormValue("first_name"), | 				"first_name":   r.FormValue("first_name"), | ||||||
| 				"last_name":    r.FormValue("last_name"), | 				"last_name":    r.FormValue("last_name"), | ||||||
| 				"email":        onboardingmap["username"], | 				"email":        onboardingmap["username"], | ||||||
|  |  | ||||||
							
								
								
									
										5
									
								
								main.go
								
								
								
								
							
							
						
						
									
										5
									
								
								main.go
								
								
								
								
							|  | @ -104,6 +104,11 @@ func main() { | ||||||
| 	application.HandleFunc("/agenda/", applicationHandler.AgendaHome) | 	application.HandleFunc("/agenda/", applicationHandler.AgendaHome) | ||||||
| 	application.HandleFunc("/agenda/create-event", applicationHandler.AgendaCreateEvent) | 	application.HandleFunc("/agenda/create-event", applicationHandler.AgendaCreateEvent) | ||||||
| 	application.HandleFunc("/agenda/{eventid}", applicationHandler.AgendaDisplayEvent) | 	application.HandleFunc("/agenda/{eventid}", applicationHandler.AgendaDisplayEvent) | ||||||
|  | 	///////////////////////////////Code to modify event///////////////////////
 | ||||||
|  | 	application.HandleFunc("/agenda/{eventid}/update", applicationHandler.AgendaUpdateEvent) | ||||||
|  | 	application.HandleFunc("/agenda/{eventid}/delete", applicationHandler.AgendaDeleteEvent) | ||||||
|  | 
 | ||||||
|  | 	/////////////////////////////////////////////////////
 | ||||||
| 	application.HandleFunc("/agenda/{eventid}/subscribe", applicationHandler.AgendaSubscribeEvent) | 	application.HandleFunc("/agenda/{eventid}/subscribe", applicationHandler.AgendaSubscribeEvent) | ||||||
| 	application.HandleFunc("/directory/", applicationHandler.DirectoryHome) | 	application.HandleFunc("/directory/", applicationHandler.DirectoryHome) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -29,6 +29,7 @@ func (renderer *Renderer) AgendaCreateEvent(w http.ResponseWriter, r *http.Reque | ||||||
| func (renderer *Renderer) AgendaDisplayEvent(w http.ResponseWriter, r *http.Request, event any, group any, subscribers map[string]any, beneficiaries any) { | func (renderer *Renderer) AgendaDisplayEvent(w http.ResponseWriter, r *http.Request, event any, group any, subscribers map[string]any, beneficiaries any) { | ||||||
| 	files := renderer.ThemeConfig.GetStringSlice("views.agenda.display_event.files") | 	files := renderer.ThemeConfig.GetStringSlice("views.agenda.display_event.files") | ||||||
| 	state := NewState(r, renderer.ThemeConfig, agendaMenu) | 	state := NewState(r, renderer.ThemeConfig, agendaMenu) | ||||||
|  | 
 | ||||||
| 	state.ViewState = map[string]any{ | 	state.ViewState = map[string]any{ | ||||||
| 		"event":         event, | 		"event":         event, | ||||||
| 		"group":         group, | 		"group":         group, | ||||||
|  | @ -65,4 +66,26 @@ func (renderer *Renderer) AgendaHistoryEvent(w http.ResponseWriter, r *http.Requ | ||||||
| 
 | 
 | ||||||
| 	renderer.Render("agenda history event", w, r, files, state) | 	renderer.Render("agenda history event", w, r, files, state) | ||||||
| } | } | ||||||
|  | 
 | ||||||
| ////////////////////////////////////////////////////////////////////////
 | ////////////////////////////////////////////////////////////////////////
 | ||||||
|  | func (renderer *Renderer) AgendaUpdateEvent(w http.ResponseWriter, r *http.Request, event any) { | ||||||
|  | 	files := renderer.ThemeConfig.GetStringSlice("views.agenda.update.files") | ||||||
|  | 	state := NewState(r, renderer.ThemeConfig, agendaMenu) | ||||||
|  | 
 | ||||||
|  | 	state.ViewState = map[string]any{ | ||||||
|  | 		"event": event, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	renderer.Render("event_update", w, r, files, state) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | func (renderer *Renderer) AgendaDeleteEvent(w http.ResponseWriter, r *http.Request, event any) { | ||||||
|  | 	files := renderer.ThemeConfig.GetStringSlice("views.agenda.delete.files") | ||||||
|  | 	state := NewState(r, renderer.ThemeConfig, agendaMenu) | ||||||
|  | 
 | ||||||
|  | 	state.ViewState = map[string]any{ | ||||||
|  | 		"event": event, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	renderer.Render("event_deleteEvent", w, r, files, state) | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue