Skip to content

Commit 79e0172

Browse files
authored
Merge pull request #433 from sinfo/staging
Update 1.2.0
2 parents 2ccf05c + 55f16be commit 79e0172

File tree

7 files changed

+82
-38
lines changed

7 files changed

+82
-38
lines changed

backend/src/models/company.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,32 @@ type CompanyParticipation struct {
3838

3939
// Some random notes about this participation.
4040
Notes string `json:"notes" bson:"notes"`
41+
42+
// Stand details
43+
StandDetails StandDetails `json:"standDetails,omitempty" bson:"standDetails,omitempty"`
44+
45+
// Stand and days at the venue
46+
Stands []Stand `json:"stands,omitempty" bson:"stands,omitempty"`
47+
48+
}
49+
50+
type Stand struct {
51+
// Stand identifier
52+
StandID string `json:"standId" bson:"standId"`
53+
54+
// Day at the venue
55+
Date *time.Time `json:"date,omitempty" bson:"date,omitempty"`
56+
}
57+
58+
type StandDetails struct {
59+
// Number of chairs required by the company
60+
Chairs int `json:"chairs" bson:"chairs"`
61+
62+
// Require front table
63+
Table bool `json:"table" bson:"table"`
64+
65+
// Require lettering
66+
Lettering bool `json:"lettering" bson:"lettering"`
4167
}
4268

4369
// CompanyBillingInfo of company
@@ -99,6 +125,12 @@ type CompanyParticipationPublic struct {
99125

100126
// Participation's package is a Package _id (see models.Package).
101127
Package PackagePublic `json:"package,omitempty"`
128+
129+
// Stand details
130+
StandDetails StandDetails `json:"standDetails,omitempty"`
131+
132+
// Days at the venue
133+
Stands []Stand `json:"stands,omitempty"`
102134
}
103135

104136
// CompanyPublic represents a company to be contacted by the team, that will hopefully participate

backend/src/models/session.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ type Session struct {
6262
Title string `json:"title" bson:"title"`
6363
Description string `json:"description" bson:"description"`
6464

65+
// Session Image
66+
Image string `json:"img,omitempty" bson:"img,omitempty"`
67+
6568
// Where the session is being held. Typically a room on the venue.
6669
Place string `json:"place" bson:"place"`
6770

@@ -89,6 +92,9 @@ type SessionPublic struct {
8992
Title string `json:"title"`
9093
Description string `json:"description"`
9194

95+
// Session Image
96+
Image string `json:"img,omitempty" bson:"img,omitempty"`
97+
9298
// Where the session is being held. Typically a room on the venue.
9399
Place string `json:"place"`
94100

backend/src/models/speaker.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ type Speaker struct {
7272
// Bio of the speaker. Careful, this will be visible on our website!
7373
Bio string `json:"bio" bson:"bio"`
7474

75+
// Company name
76+
CompanyName string `json:"companyName" bson:"companyName"`
77+
7578
// This is only visible by the team. Praise and trash talk at will.
7679
Notes string `json:"notes" bson:"notes"`
7780
Images SpeakerImages `json:"imgs" bson:"imgs"`
@@ -86,7 +89,7 @@ type SpeakerImagesPublic struct {
8689

8790
// Speaker's company photo. This is a URL pointing to the photo, stored somewhere. It will
8891
// be visible on our website.
89-
Company string `json:"company" bson:"company"`
92+
Company string `json:"company,omitempty" bson:"company"`
9093
}
9194

9295
type SpeakerParticipationPublic struct {
@@ -112,6 +115,9 @@ type SpeakerPublic struct {
112115
// Bio of the speaker. Careful, this will be visible on our website!
113116
Bio string `json:"bio" bson:"bio"`
114117

118+
// Company name
119+
CompanyName string `json:"companyName,omitempty" bson:"companyName"`
120+
115121
Images SpeakerImagesPublic `json:"imgs" bson:"imgs"`
116122
Participations []SpeakerParticipationPublic `json:"participation" bson:"participations"`
117123
}

backend/src/mongodb/company.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ func companyToPublic(company models.Company, eventID *int) (*models.CompanyPubli
319319
Event: p.Event,
320320
Partner: participation.Partner,
321321
Package: models.PackagePublic{},
322+
StandDetails: participation.StandDetails,
323+
Stands: participation.Stands,
322324
}
323325

324326
if participation.Package != nil {

backend/src/mongodb/session.go

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func sessionToPublic(session models.Session, eventID *int) (*models.SessionPubli
3737
Begin: session.Begin,
3838
End: session.End,
3939
Title: session.Title,
40+
Image: session.Image,
4041
Description: session.Description,
4142
Place: session.Place,
4243
Kind: session.Kind,
@@ -492,55 +493,27 @@ func (s *SessionsType) GetSessions(options GetSessionsOptions) ([]*models.Sessio
492493
type GetSessionsPublicOptions struct {
493494
EventID *int
494495
Kind *models.SessionKind
496+
Company *primitive.ObjectID
497+
Speaker *primitive.ObjectID
495498
}
496499

497500
// GetPublicSessions gets all sessions specified with a query to be shown publicly
498501
func (s *SessionsType) GetPublicSessions(options GetSessionsPublicOptions) ([]*models.SessionPublic, error) {
499502
ctx = context.Background()
500503

501504
var public = make([]*models.SessionPublic, 0)
502-
var filtered = make([]*models.Session, 0)
503505
var sessions []*models.Session
504506
var err error
505507

506-
if currentPublicCompanies != nil {
507-
508-
var filtered = make([]*models.SessionPublic, 0)
509-
510-
if options.Kind != nil {
511-
512-
for _, s := range *currentPublicSessions {
513-
if s.Kind == *options.Kind {
514-
filtered = append(filtered, s)
515-
}
516-
}
517-
518-
} else {
519-
filtered = *currentPublicSessions
520-
}
521-
522-
// return cached value
523-
return filtered, nil
524-
525-
}
526-
527-
sessions, err = Sessions.GetSessions(GetSessionsOptions{Event: options.EventID})
508+
sessions, err = Sessions.GetSessions(GetSessionsOptions{
509+
Event: options.EventID,
510+
Kind: options.Kind,
511+
Company: options.Company,
512+
Speaker: options.Speaker})
528513
if err != nil {
529514
return nil, err
530515
}
531516

532-
if options.Kind != nil {
533-
534-
for _, s := range sessions {
535-
if s.Kind == *options.Kind {
536-
filtered = append(filtered, s)
537-
}
538-
}
539-
540-
} else {
541-
filtered = sessions
542-
}
543-
544517
var event *models.Event
545518
if options.EventID == nil {
546519
event, err = Events.GetCurrentEvent()
@@ -554,15 +527,15 @@ func (s *SessionsType) GetPublicSessions(options GetSessionsPublicOptions) ([]*m
554527
}
555528
}
556529

557-
for _, session := range filtered {
530+
for _, session := range sessions {
558531
p, err := sessionToPublic(*session, &event.ID)
559532
if err != nil {
560533
return nil, err
561534
}
562535
public = append(public, p)
563536
}
564537

565-
if options.EventID == nil && options.Kind == nil && currentPublicSessions == nil {
538+
if options.EventID == nil && options.Kind == nil && options.Company == nil && options.Speaker == nil && currentPublicSessions == nil {
566539
currentPublicSessions = &public
567540
}
568541

backend/src/mongodb/speaker.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func speakerToPublic(speaker models.Speaker, eventID *int) (*models.SpeakerPubli
3737
Name: speaker.Name,
3838
Bio: speaker.Bio,
3939
Title: speaker.Title,
40+
CompanyName: speaker.CompanyName,
4041
Images: models.SpeakerImagesPublic{
4142
Speaker: speaker.Images.Speaker,
4243
Company: speaker.Images.Company,

backend/src/router/session.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ func getPublicSessions(w http.ResponseWriter, r *http.Request) {
150150

151151
event := urlQuery.Get("event")
152152
kind := urlQuery.Get("kind")
153+
company := urlQuery.Get("company")
154+
speaker := urlQuery.Get("speaker")
153155

154156
if len(event) > 0 {
155157
eventValue, err := strconv.Atoi(event)
@@ -180,6 +182,28 @@ func getPublicSessions(w http.ResponseWriter, r *http.Request) {
180182
options.Kind = kindValue
181183
}
182184

185+
if len(company) > 0 {
186+
companyValue, err := primitive.ObjectIDFromHex(company)
187+
188+
if err != nil {
189+
json.NewEncoder(w).Encode(make([]*models.Session, 0))
190+
return
191+
}
192+
193+
options.Company = &companyValue
194+
}
195+
196+
if len(speaker) > 0 {
197+
speakerValue, err := primitive.ObjectIDFromHex(speaker)
198+
199+
if err != nil {
200+
json.NewEncoder(w).Encode(make([]*models.Session, 0))
201+
return
202+
}
203+
204+
options.Speaker = &speakerValue
205+
}
206+
183207
sessions, err := mongodb.Sessions.GetPublicSessions(options)
184208

185209
if err != nil {

0 commit comments

Comments
 (0)