Skip to content

Commit 9554c34

Browse files
authored
Merge branch 'master' into 472-complete-communications
2 parents af07778 + 9e91b47 commit 9554c34

File tree

92 files changed

+6224
-1556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+6224
-1556
lines changed

.github/workflows/lint.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Lint and Format on PR
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
frontend-lint:
8+
name: Frontend ESLint & Prettier
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: "23"
18+
cache: "npm"
19+
cache-dependency-path: frontend/package-lock.json
20+
21+
- name: Install frontend dependencies
22+
working-directory: frontend
23+
run: npm ci
24+
25+
- name: Run ESLint (auto-fix)
26+
working-directory: frontend
27+
run: npm run lint
28+
29+
- name: Run Prettier check
30+
working-directory: frontend
31+
run: npx prettier --check .
32+
33+
- name: Build frontend
34+
working-directory: frontend
35+
run: npm run build

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,6 @@ deck2.sh
122122
/ios/Flutter/Release.xcconfig
123123
/frontend/ios/Flutter/Debug.xcconfig
124124
/frontend/ios/Flutter/Release.xcconfig
125-
Podfile
125+
Podfile
126+
127+
backend/.vendor-new/

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"vue.volar",
4+
"golang.go",
5+
"esbenp.prettier-vscode",
6+
"dbaeumer.vscode-eslint"
7+
]
8+
}

.vscode/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll": "always"
5+
},
6+
"[vue]": {
7+
"editor.defaultFormatter": "esbenp.prettier-vscode"
8+
},
9+
"[javascript]": {
10+
"editor.defaultFormatter": "esbenp.prettier-vscode"
11+
},
12+
"[typescript]": {
13+
"editor.defaultFormatter": "esbenp.prettier-vscode"
14+
}
15+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Version 2 of eventdeck
88

99
## Documentation
1010

11-
- swagger: http://petstore.swagger.io/?url=http%3A%2F%2Flocalhost%3A8080%2Fstatic%2Fswagger.json#/auth/authCallback
11+
- swagger: make run-doc

backend/src/config/config.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ const (
5151
keyPort string = "PORT"
5252

5353
keyDatabaseURI string = "DB_URL"
54-
deckDbURL string = "DECK_DB_URL"
5554
keyDatabaseName string = "DB_NAME"
5655
keyCallbackURL string = "CALLBACK_URL"
5756

@@ -67,6 +66,7 @@ const (
6766
keySpacesKey string = "DO_SPACES_KEY"
6867

6968
keyAuthRedirectionURL string = "AUTH_REDIRECTION_URL"
69+
keyProduction string = "PRODUCTION"
7070
)
7171

7272
func set(variable *string, key string, mandatory bool) {
@@ -75,7 +75,17 @@ func set(variable *string, key string, mandatory bool) {
7575
} else if viper.IsSet(key) {
7676
*variable = viper.GetString(key)
7777
} else if mandatory {
78-
log.Fatal(fmt.Sprintf("%s", key) + " not set")
78+
log.Fatalf("%s not set", key)
79+
}
80+
}
81+
82+
func setBool(variable *bool, key string, mandatory bool) {
83+
if viper.IsSet(keyPrefix + "_" + key) {
84+
*variable = viper.GetBool(keyPrefix + "_" + key)
85+
} else if viper.IsSet(key) {
86+
*variable = viper.GetBool(key)
87+
} else if mandatory {
88+
log.Fatalf("%s not set", key)
7989
}
8090
}
8191

@@ -89,13 +99,13 @@ func InitializeConfig(filename *string) {
8999

90100
if file {
91101
if err := godotenv.Load(*filename); err != nil {
92-
fmt.Printf("Error loading .env file: %v\n", err)
93-
}
102+
fmt.Printf("Error loading .env file: %v\n", err)
103+
}
94104
}
95105

96106
viper.SetEnvPrefix(keyPrefix)
97107
viper.AutomaticEnv()
98-
108+
99109
set(&Host, keyHost, false)
100110
set(&Port, keyPort, false)
101111

@@ -116,6 +126,8 @@ func InitializeConfig(filename *string) {
116126

117127
set(&AuthRedirectionURL, keyAuthRedirectionURL, true)
118128

129+
// Load boolean flags from env
130+
setBool(&Production, keyProduction, false)
119131
}
120132

121133
func SetTestingEnv() {

backend/src/models/member.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ type Member struct {
2424
SINFOID string `json:"sinfoid" bson:"sinfoid"`
2525

2626
// Contact is an _id of Contact (see models.Contact).
27-
Contact primitive.ObjectID `json:"contact" bson:"contact"`
28-
ContactObject *Contact `json:"contactObject,omitempty" bson:"-"`
27+
Contact primitive.ObjectID `json:"contact" bson:"contact"`
28+
ContactObject *Contact `json:"contactObject,omitempty" bson:"-"`
2929
}
3030

3131
// MemberPublic is the public information about a member
@@ -37,6 +37,14 @@ type MemberPublic struct {
3737
Image string `json:"img" bson:"img"`
3838

3939
Socials ContactSocials `json:"socials"`
40+
41+
// Team is the name of the team this member belongs to for the
42+
// event being queried (when available). Omitted when not set.
43+
Team string `json:"team,omitempty" bson:"-"`
44+
45+
// SinfoEmail is the member's full SINFO email (e.g. john.doe@sinfo.org).
46+
// This is derived from the Member.SINFOID value.
47+
SinfoEmail string `json:"sinfo_email,omitempty" bson:"-"`
4048
}
4149

4250
type AuthorizationCredentials struct {

backend/src/mongodb/company.go

Lines changed: 78 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type CompaniesType struct {
2626
// Cached version of the public companies for the current event
2727
var currentPublicCompanies *[]*models.CompanyPublic
2828

29-
//ResetCurrentPublicCompanies resets current public companies
29+
// ResetCurrentPublicCompanies resets current public companies
3030
func ResetCurrentPublicCompanies() {
3131
currentPublicCompanies = nil
3232
}
@@ -76,17 +76,17 @@ func (c *CompaniesType) CreateCompany(data CreateCompanyData) (*models.Company,
7676
},
7777
"mails": []models.ContactMail{},
7878
})
79-
if err != nil {
80-
return nil, err
81-
}
79+
if err != nil {
80+
return nil, err
81+
}
8282

8383
insertResult, err := c.Collection.InsertOne(ctx, bson.M{
8484
"name": data.Name,
8585
"description": data.Description,
8686
"site": data.Site,
8787
"employers": []primitive.ObjectID{},
8888
"participations": []models.CompanyParticipation{},
89-
"contact": createdContact.InsertedID.(primitive.ObjectID),
89+
"contact": createdContact.InsertedID.(primitive.ObjectID),
9090
})
9191

9292
if err != nil {
@@ -316,11 +316,11 @@ func companyToPublic(company models.Company, eventID *int) (*models.CompanyPubli
316316
var participationObj models.CompanyParticipationPublic
317317

318318
participationObj = models.CompanyParticipationPublic{
319-
Event: p.Event,
320-
Partner: participation.Partner,
321-
Package: models.PackagePublic{},
322-
StandDetails: participation.StandDetails,
323-
Stands: participation.Stands,
319+
Event: p.Event,
320+
Partner: participation.Partner,
321+
Package: models.PackagePublic{},
322+
StandDetails: participation.StandDetails,
323+
Stands: participation.Stands,
324324
}
325325

326326
if participation.Package != nil {
@@ -732,16 +732,20 @@ func (c *CompaniesType) UpdateCompanyParticipation(companyID primitive.ObjectID,
732732
return nil, err
733733
}
734734

735-
var updateQuery = bson.M{
736-
"$set": bson.M{
737-
"participations.$.member": *data.Member,
738-
"participations.$.partner": *data.Partner,
739-
"participations.$.notes": *data.Notes,
740-
},
735+
setFields := bson.M{
736+
"participations.$.member": *data.Member,
737+
"participations.$.partner": *data.Partner,
738+
"participations.$.notes": *data.Notes,
741739
}
742740

743741
if data.Confirmed != nil {
744-
updateQuery["participations.$.confirmed"] = data.Confirmed.UTC()
742+
setFields["participations.$.confirmed"] = data.Confirmed.UTC()
743+
} else {
744+
setFields["participations.$.confirmed"] = nil
745+
}
746+
747+
var updateQuery = bson.M{
748+
"$set": setFields,
745749
}
746750

747751
var filterQuery = bson.M{"_id": companyID, "participations.event": currentEvent.ID}
@@ -937,39 +941,39 @@ func (c *CompaniesType) UpdateCompanyPublicImage(companyID primitive.ObjectID, u
937941
func (c *CompaniesType) DeleteCompany(companyID primitive.ObjectID) (*models.Company, error) {
938942

939943
ctx := context.Background()
940-
var company models.Company
944+
var company models.Company
941945

942946
currentCompany, err := Companies.GetCompany(companyID)
943947
if err != nil {
944948
return nil, err
945949
}
946950

947-
for _, participation := range currentCompany.Participations {
948-
_, err := c.DeleteCompanyParticipation(companyID, participation.Event)
949-
if err != nil {
950-
return nil, err
951-
}
952-
}
951+
for _, participation := range currentCompany.Participations {
952+
_, err := c.DeleteCompanyParticipation(companyID, participation.Event)
953+
if err != nil {
954+
return nil, err
955+
}
956+
}
953957

954-
sessions, err := Sessions.GetSessions(GetSessionsOptions{Company: &companyID})
958+
sessions, err := Sessions.GetSessions(GetSessionsOptions{Company: &companyID})
955959
if err != nil {
956960
return nil, err
957961
}
958962

959-
for _, session := range sessions {
960-
_, err := Sessions.DeleteSession(session.ID)
961-
if err != nil {
962-
return nil, err
963-
}
964-
}
963+
for _, session := range sessions {
964+
_, err := Sessions.DeleteSession(session.ID)
965+
if err != nil {
966+
return nil, err
967+
}
968+
}
965969

966-
err = c.Collection.FindOneAndDelete(ctx, bson.M{"_id": companyID}).Decode(&company)
967-
if err != nil {
968-
return nil, err
969-
}
970+
err = c.Collection.FindOneAndDelete(ctx, bson.M{"_id": companyID}).Decode(&company)
971+
if err != nil {
972+
return nil, err
973+
}
970974

971-
// Ignore error, if contact doesn't exist, it's ok.
972-
Contacts.DeleteContact(company.Contact)
975+
// Ignore error, if contact doesn't exist, it's ok.
976+
Contacts.DeleteContact(company.Contact)
973977

974978
return &company, nil
975979
}
@@ -1297,45 +1301,44 @@ func (c *CompaniesType) RemoveCompanyParticipationBilling(companyID primitive.Ob
12971301

12981302
// DeleteCompanyParticipation deletes a company's participation related to the eventID
12991303
func (c *CompaniesType) DeleteCompanyParticipation(companyID primitive.ObjectID, eventID int) (*models.Company, error) {
1300-
ctx := context.Background();
1301-
var updatedCompany models.Company
1302-
1303-
company, err := c.GetCompany(companyID)
1304-
if err != nil {
1305-
return nil, err
1306-
}
1307-
1308-
for _, p := range company.Participations {
1309-
if p.Event == eventID {
1310-
for _, communication := range p.Communications {
1311-
_, err := c.DeleteCompanyThread(companyID, communication)
1312-
if err != nil {
1313-
return nil, err
1314-
}
1315-
}
1316-
}
1317-
}
1318-
1319-
var updateQuery = bson.M{
1320-
"$pull": bson.M{
1321-
"participations": bson.M{
1322-
"event": eventID,
1323-
},
1324-
},
1325-
}
1326-
1327-
var filterQuery = bson.M{"_id": companyID}
1328-
1329-
var optionsQuery = options.FindOneAndUpdate()
1330-
optionsQuery.SetReturnDocument(options.After)
1331-
1332-
if err := c.Collection.FindOneAndUpdate(ctx, filterQuery, updateQuery, optionsQuery).Decode(&updatedCompany); err != nil {
1333-
return nil, err
1334-
}
1335-
1336-
return &updatedCompany, nil
1337-
}
1304+
ctx := context.Background()
1305+
var updatedCompany models.Company
1306+
1307+
company, err := c.GetCompany(companyID)
1308+
if err != nil {
1309+
return nil, err
1310+
}
1311+
1312+
for _, p := range company.Participations {
1313+
if p.Event == eventID {
1314+
for _, communication := range p.Communications {
1315+
_, err := c.DeleteCompanyThread(companyID, communication)
1316+
if err != nil {
1317+
return nil, err
1318+
}
1319+
}
1320+
}
1321+
}
13381322

1323+
var updateQuery = bson.M{
1324+
"$pull": bson.M{
1325+
"participations": bson.M{
1326+
"event": eventID,
1327+
},
1328+
},
1329+
}
1330+
1331+
var filterQuery = bson.M{"_id": companyID}
1332+
1333+
var optionsQuery = options.FindOneAndUpdate()
1334+
optionsQuery.SetReturnDocument(options.After)
1335+
1336+
if err := c.Collection.FindOneAndUpdate(ctx, filterQuery, updateQuery, optionsQuery).Decode(&updatedCompany); err != nil {
1337+
return nil, err
1338+
}
1339+
1340+
return &updatedCompany, nil
1341+
}
13391342

13401343
// FindThread finds a thread in a company
13411344
func (c *CompaniesType) FindThread(threadID primitive.ObjectID) (*models.Company, error) {

0 commit comments

Comments
 (0)