Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #217

Merged
merged 54 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
6af18e7
crew event participation
TobiKaestle Oct 23, 2023
50b9063
wip
TobiKaestle Oct 26, 2023
41bf65f
set index
deinelieblings Jul 11, 2024
1280dd0
fix bug in currencies
deinelieblings Jul 11, 2024
52ea21a
Merge pull request #202 from Viva-con-Agua/dk/taking_update
deinelieblings Jul 11, 2024
4fe0bdb
can't delete takings that depending on an event
deinelieblings Jul 12, 2024
3d2459a
Merge pull request #203 from Viva-con-Agua/dk/taking_update
deinelieblings Jul 12, 2024
820cd7d
update for date_of_taking
deinelieblings Jul 12, 2024
ec99c4a
Merge pull request #204 from Viva-con-Agua/dk/taking_update
deinelieblings Jul 12, 2024
2eb2a32
solves #180. Artist searchable
deinelieblings Aug 20, 2024
62bc35c
solves #175
deinelieblings Aug 20, 2024
33fc026
solves #172
deinelieblings Aug 20, 2024
a653c87
solves #174
deinelieblings Aug 21, 2024
49cbbc7
add receipt file upload get and delete
deinelieblings Aug 21, 2024
31a1478
Merge pull request #207 from Viva-con-Agua/dk/taking_update
TobiKaestle Aug 22, 2024
19b89ff
refers to #178
deinelieblings Aug 23, 2024
b2ec171
set last_login_date of the current date
deinelieblings Sep 11, 2024
701662b
add permissions for deposit_receipt
deinelieblings Sep 11, 2024
977f736
solves #206
deinelieblings Sep 11, 2024
38bd003
updated eventlist
TobiKaestle Sep 11, 2024
fa7302c
updated total count
TobiKaestle Sep 11, 2024
0a5471a
removed fmt
TobiKaestle Sep 11, 2024
05d7199
removed login email
TobiKaestle Sep 11, 2024
5e70c0d
removed empty id, added total to default
TobiKaestle Sep 11, 2024
8c4751c
added search
TobiKaestle Sep 11, 2024
385c0de
download all images as zip
deinelieblings Sep 11, 2024
674e84d
Merge pull request #210 from Viva-con-Agua/dk/receipt_deposits
deinelieblings Sep 11, 2024
2b6cbf5
Merge branch 'develop' into feature/event_list
deinelieblings Sep 11, 2024
bab0df4
Merge pull request #209 from Viva-con-Agua/feature/event_list
deinelieblings Sep 11, 2024
0f47f87
publish roles to nats, handle new roles
TobiKaestle Sep 24, 2024
55282f5
required for webapp issue
deinelieblings Sep 26, 2024
3457c04
solves #212
deinelieblings Sep 27, 2024
a553440
Merge pull request #211 from Viva-con-Agua/dk/webapp_#329
TobiKaestle Sep 27, 2024
0a6f30c
add modified to taking
deinelieblings Sep 27, 2024
38242be
Merge pull request #213 from Viva-con-Agua/dk/webapp_#329
deinelieblings Sep 27, 2024
7177b8a
added organisation handling
TobiKaestle Sep 28, 2024
5783af4
added permission to user list, updated organisation, added organisati…
TobiKaestle Sep 29, 2024
9b8bf8f
updated permissions and organisation
TobiKaestle Sep 30, 2024
d13e51d
updated update
TobiKaestle Sep 30, 2024
b9040f4
Merge branch 'develop' into feature/publish_roles
TobiKaestle Sep 30, 2024
f630191
updated accesstoken
TobiKaestle Sep 30, 2024
d0e4b04
added access token
TobiKaestle Sep 30, 2024
abd6078
pre commit
TobiKaestle Oct 30, 2024
c5a38a5
merge with develop
TobiKaestle Oct 30, 2024
5415921
added event history
TobiKaestle Nov 1, 2024
2f2fd45
added organisation
TobiKaestle Nov 3, 2024
3c22b61
naming
TobiKaestle Nov 4, 2024
469f106
updated count
TobiKaestle Nov 4, 2024
7379f57
merge with organisations
TobiKaestle Nov 4, 2024
fe52f9d
Merge pull request #214 from Viva-con-Agua/feature/publish_roles
TobiKaestle Nov 4, 2024
c5ab3a1
fixed counts, added default_asp to organisations
TobiKaestle Nov 7, 2024
afd5344
changes
deinelieblings Nov 8, 2024
d69ae14
Merge pull request #215 from Viva-con-Agua/feature/crew_event
TobiKaestle Nov 22, 2024
0acd065
updated update to update vmdb update update
TobiKaestle Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .k8s/mongodb_deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
labels: *labels
spec:
containers:
- image: mongo
- image: mongo:7.0.15
name: pool-backend-db
args: ["--dbpath", "/data/db"]
volumeMounts:
Expand Down
17 changes: 8 additions & 9 deletions dao/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ import (
"pool-backend/models"

"github.com/Viva-con-Agua/vcago/vmdb"
"github.com/Viva-con-Agua/vcapool"
"go.mongodb.org/mongo-driver/bson"
)

func AddressInsert(ctx context.Context, i *models.AddressCreate, token *vcapool.AccessToken) (result *models.Address, err error) {
func AddressInsert(ctx context.Context, i *models.AddressCreate, token *models.AccessToken) (result *models.Address, err error) {
result = i.Address(token.ID)
if err = AddressesCollection.InsertOne(ctx, result); err != nil {
return
}
return
}

func UsersAddressInsert(ctx context.Context, i *models.UsersAddressCreate, token *vcapool.AccessToken) (result *models.Address, err error) {
func UsersAddressInsert(ctx context.Context, i *models.UsersAddressCreate, token *models.AccessToken) (result *models.Address, err error) {
if err = models.AddressPermission(token); err != nil {
return
}
Expand All @@ -28,7 +27,7 @@ func UsersAddressInsert(ctx context.Context, i *models.UsersAddressCreate, token
return
}

func AddressGet(ctx context.Context, i *models.AddressQuery, token *vcapool.AccessToken) (result *[]models.Address, err error) {
func AddressGet(ctx context.Context, i *models.AddressQuery, token *models.AccessToken) (result *[]models.Address, err error) {
filter := i.PermittedFilter(token)
result = new([]models.Address)
if err = AddressesCollection.Find(ctx, filter, result); err != nil {
Expand All @@ -37,15 +36,15 @@ func AddressGet(ctx context.Context, i *models.AddressQuery, token *vcapool.Acce
return
}

func AddressGetByID(ctx context.Context, i *models.AddressParam, token *vcapool.AccessToken) (result *models.Address, err error) {
func AddressGetByID(ctx context.Context, i *models.AddressParam, token *models.AccessToken) (result *models.Address, err error) {
filter := i.PermittedFilter(token)
if err = AddressesCollection.FindOne(ctx, filter, &result); err != nil {
return
}
return
}

func UsersAddressUpdate(ctx context.Context, i *models.AddressUpdate, token *vcapool.AccessToken) (result *models.Address, err error) {
func UsersAddressUpdate(ctx context.Context, i *models.AddressUpdate, token *models.AccessToken) (result *models.Address, err error) {
if err = models.AddressPermission(token); err != nil {

return
Expand All @@ -56,15 +55,15 @@ func UsersAddressUpdate(ctx context.Context, i *models.AddressUpdate, token *vca
return
}

func AddressUpdate(ctx context.Context, i *models.AddressUpdate, token *vcapool.AccessToken) (result *models.Address, err error) {
func AddressUpdate(ctx context.Context, i *models.AddressUpdate, token *models.AccessToken) (result *models.Address, err error) {
filter := i.PermittedFilter(token)
if err = AddressesCollection.UpdateOne(ctx, filter, vmdb.UpdateSet(i), &result); err != nil {
return
}
return
}

func AddressDelete(ctx context.Context, i *models.AddressParam, token *vcapool.AccessToken) (result *models.NVM, err error) {
func AddressDelete(ctx context.Context, i *models.AddressParam, token *models.AccessToken) (result *models.NVM, err error) {
filter := i.PermittedFilter(token)
if err = AddressesCollection.DeleteOne(ctx, filter); err != nil {
return
Expand All @@ -75,7 +74,7 @@ func AddressDelete(ctx context.Context, i *models.AddressParam, token *vcapool.A
return
}

func UsersAddressDelete(ctx context.Context, i *models.AddressParam, token *vcapool.AccessToken) (result *models.NVM, err error) {
func UsersAddressDelete(ctx context.Context, i *models.AddressParam, token *models.AccessToken) (result *models.NVM, err error) {
if err = models.AddressPermission(token); err != nil {
return
}
Expand Down
7 changes: 3 additions & 4 deletions dao/artist.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"pool-backend/models"

"github.com/Viva-con-Agua/vcago/vmdb"
"github.com/Viva-con-Agua/vcapool"
)

func ArtistInsert(ctx context.Context, i *models.ArtistCreate, token *vcapool.AccessToken) (result *models.Artist, err error) {
func ArtistInsert(ctx context.Context, i *models.ArtistCreate, token *models.AccessToken) (result *models.Artist, err error) {
if err = models.ArtistPermission(token); err != nil {
return
}
Expand Down Expand Up @@ -36,7 +35,7 @@ func ArtistGetByID(ctx context.Context, i *models.ArtistParam) (result *models.A
return
}

func ArtistUpdate(ctx context.Context, i *models.ArtistUpdate, token *vcapool.AccessToken) (result *models.Artist, err error) {
func ArtistUpdate(ctx context.Context, i *models.ArtistUpdate, token *models.AccessToken) (result *models.Artist, err error) {
if err = models.ArtistPermission(token); err != nil {
return
}
Expand All @@ -47,7 +46,7 @@ func ArtistUpdate(ctx context.Context, i *models.ArtistUpdate, token *vcapool.Ac
return
}

func ArtistDelete(ctx context.Context, i *models.ArtistParam, token *vcapool.AccessToken) (err error) {
func ArtistDelete(ctx context.Context, i *models.ArtistParam, token *models.AccessToken) (err error) {
if err = models.ArtistDeletePermission(token); err != nil {
return
}
Expand Down
53 changes: 48 additions & 5 deletions dao/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ var (
AvatarCollection *vmdb.Collection

// PoolRoleCollection represents the database collection of the PoolRole Collection.
PoolRoleCollection *vmdb.Collection
PoolRoleHistoryCollection *vmdb.Collection
PoolRoleCollection *vmdb.Collection
PoolRoleHistoryCollection *vmdb.Collection
EventStateHistoryCollection *vmdb.Collection

MailboxCollection *vmdb.Collection
MessageCollection *vmdb.Collection

OrganisationCollection *vmdb.Collection
ArtistCollection *vmdb.Collection
ParticipationCollection *vmdb.Collection
OrganizerCollection *vmdb.Collection
Expand All @@ -63,20 +65,27 @@ var (

ReasonForPaymentCollection *vmdb.Collection
UserViewCollection *vmdb.Collection
EventViewCollection *vmdb.Collection
PublicEventViewCollection *vmdb.Collection

NewsletterCollection *vmdb.Collection

DepositUnitTakingPipe = vmdb.NewPipeline()
ParticipationEventPipe = vmdb.NewPipeline()
ActitityUserPipe = vmdb.NewPipeline()
UserPipe = vmdb.NewPipeline()
EventPipe = vmdb.NewPipeline()
PublicEventPipe = vmdb.NewPipeline()
UpdateCollection *vmdb.Collection
Updates *vmdb.CollectionUpdate
ReceiptFileCollection *vmdb.Collection

TestLogin bool
)

func InitialDatabase() {
Database = vmdb.NewDatabase("pool-backend").Connect()
Database.Database.Collection(models.CrewCollection).Indexes().DropAll(context.Background())

// UserCollection represents the database collection of the User model.
UserCollection = Database.Collection(models.UserCollection).CreateIndex("email", true)
Expand All @@ -94,7 +103,7 @@ func InitialDatabase() {
AddressesCollection = Database.Collection(models.AddressesCollection).CreateIndex("user_id", true)

// CrewsCollection represents the database collection of the Crew model.
CrewsCollection = Database.Collection(models.CrewCollection).CreateIndex("name", true)
CrewsCollection = Database.Collection(models.CrewCollection).CreateIndex("name", true).CreateIndex("organisation_id", false)

// ProfileCollection represents the database collection of the Profile model.
ProfileCollection = Database.Collection(models.ProfileCollection).CreateIndex("user_id", true)
Expand All @@ -105,11 +114,13 @@ func InitialDatabase() {
// PoolRoleCollection represents the database collection of the PoolRole Collection.
PoolRoleCollection = Database.Collection(models.PoolRoleCollection).CreateIndex("user_id", false).CreateMultiIndex(bson.D{{Key: "name", Value: 1}, {Key: "user_id", Value: 1}}, true)
PoolRoleHistoryCollection = Database.Collection(models.PoolRoleHistoryCollection).CreateIndex("user_id", false).CreateIndex("crew_id", false)
EventStateHistoryCollection = Database.Collection(models.EventStateHistoryCollection).CreateIndex("user_id", false).CreateIndex("crew_id", false).CreateIndex("event_id", false).CreateIndex("new_state", false).CreateIndex("date", false)

//
MailboxCollection = Database.Collection(models.MailboxCollection)

MessageCollection = Database.Collection(models.MessageCollection).CreateIndex("user_id", false).CreateIndex("mailbox_id", false)
OrganisationCollection = Database.Collection(models.OrganisationCollection).CreateIndex("name", true).CreateIndex("abbreviation", true)
ArtistCollection = Database.Collection(models.ArtistCollection).CreateIndex("name", true)
ParticipationCollection = Database.Collection(models.ParticipationCollection).CreateIndex("user_id", false).CreateMultiIndex(
bson.D{
Expand All @@ -119,9 +130,9 @@ func InitialDatabase() {
OrganizerCollection = Database.Collection(models.OrganizerCollection).CreateIndex("name", true)
EventCollection = Database.Collection(models.EventCollection)
SourceCollection = Database.Collection(models.SourceCollection)
TakingCollection = Database.Collection(models.TakingCollection)
TakingCollection = Database.Collection(models.TakingCollection).CreateIndex("crew_id", false)
DepositCollection = Database.Collection(models.DepositCollection)
DepositUnitCollection = Database.Collection(models.DepositUnitCollection).CreateMultiIndex(bson.D{{Key: "taking_id", Value: 1}, {Key: "deposit_id", Value: 1}}, true)
DepositUnitCollection = Database.Collection(models.DepositUnitCollection).CreateMultiIndex(bson.D{{Key: "taking_id", Value: 1}, {Key: "deposit_id", Value: 1}}, true).CreateIndex("taking_id", false).CreateIndex("deposit_id", false)

FSChunkCollection = Database.Collection(models.FSChunkCollection)
FSFilesCollection = Database.Collection(models.FSFilesCollection)
Expand All @@ -148,6 +159,30 @@ func InitialDatabase() {
)
UserViewCollection = Database.Collection(models.UserView)

PublicEventPipe.Lookup(models.ParticipationCollection, "_id", "event_id", "participations")
PublicEventPipe.LookupUnwind(models.OrganizerCollection, "organizer_id", "_id", "organizer")
PublicEventPipe.LookupList(models.ArtistCollection, "artist_ids", "_id", "artists")
PublicEventPipe.LookupUnwind(models.CrewCollection, "crew_id", "_id", "crew")
Database.Database.CreateView(
context.Background(),
models.PublicEventView,
models.EventCollection,
models.EventPipelinePublic().Pipe,
)
PublicEventViewCollection = Database.Collection(models.PublicEventView)

EventPipe.Lookup(models.ParticipationCollection, "_id", "event_id", "participations")
EventPipe.LookupUnwind(models.OrganizerCollection, "organizer_id", "_id", "organizer")
EventPipe.LookupList(models.ArtistCollection, "artist_ids", "_id", "artists")
EventPipe.LookupUnwind(models.CrewCollection, "crew_id", "_id", "crew")
Database.Database.CreateView(
context.Background(),
models.EventView,
models.EventCollection,
models.EventPipeline(&models.AccessToken{ID: ""}),
)
EventViewCollection = Database.Collection(models.EventView)

DepositUnitTakingPipe.LookupUnwind(models.DepositCollection, "deposit_id", "_id", "deposit")
Database.Database.CreateView(
context.Background(),
Expand All @@ -171,6 +206,14 @@ func InitialDatabase() {
ActitityUserPipe.Pipe,
)
UpdateCollection = Database.Collection("updates").CreateIndex("name", true)
Updates = vmdb.NewCollectionUpdate(UpdateCollection)
ReceiptFileCollection = Database.Collection(models.ReceiptFileCollection).CreateIndex("deposit_id", false)
Database.Database.CreateView(
context.Background(),
models.TakingDepositView,
models.TakingCollection,
models.TakingPipelineDeposit().Pipe,
)
}

func FixDatabase() {
Expand Down
28 changes: 15 additions & 13 deletions dao/crew.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (

"github.com/Viva-con-Agua/vcago"
"github.com/Viva-con-Agua/vcago/vmdb"
"github.com/Viva-con-Agua/vcapool"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/options"
)

func CrewInsert(ctx context.Context, i *models.CrewCreate, token *vcapool.AccessToken) (result *models.Crew, err error) {
func CrewInsert(ctx context.Context, i *models.CrewCreate, token *models.AccessToken) (result *models.Crew, err error) {

if err = models.CrewPermission(token); err != nil {
return
Expand All @@ -32,19 +32,22 @@ func CrewInsert(ctx context.Context, i *models.CrewCreate, token *vcapool.Access
return
}

func CrewGet(ctx context.Context, i *models.CrewQuery, token *vcapool.AccessToken) (result *[]models.Crew, err error) {
func CrewGet(ctx context.Context, i *models.CrewQuery, token *models.AccessToken) (result *[]models.Crew, err error) {
if err = models.CrewPermission(token); err != nil {
return
}
filter := i.Filter()
result = new([]models.Crew)
if err = CrewsCollection.Find(ctx, filter, result); err != nil {
opt := options.Find().SetSort(bson.D{{Key: "name", Value: 1}})
opt.Collation = &options.Collation{Locale: "en", Strength: 2}

if err = CrewsCollection.Aggregate(ctx, models.CrewPipeline().Match(filter).Pipe, result); err != nil {
return
}
return
}

func CrewGetByID(ctx context.Context, i *models.CrewParam, token *vcapool.AccessToken) (result *models.Crew, err error) {
func CrewGetByID(ctx context.Context, i *models.CrewParam, token *models.AccessToken) (result *models.Crew, err error) {
filter := i.PermittedFilter(token)
if err = CrewsCollection.FindOne(ctx, filter, &result); err != nil {
return
Expand All @@ -61,15 +64,15 @@ func CrewPublicGet(ctx context.Context, i *models.CrewQuery) (result *[]models.C
return
}

func CrewGetAsMember(ctx context.Context, i *models.CrewQuery, token *vcapool.AccessToken) (result *models.Crew, err error) {
func CrewGetAsMember(ctx context.Context, i *models.CrewQuery, token *models.AccessToken) (result *models.Crew, err error) {
filter := i.PermittedFilter(token)
if err = CrewsCollection.FindOne(ctx, filter, &result); err != nil {
return
}
return
}

func CrewUpdate(ctx context.Context, i *models.CrewUpdate, token *vcapool.AccessToken) (result *models.Crew, err error) {
func CrewUpdate(ctx context.Context, i *models.CrewUpdate, token *models.AccessToken) (result *models.Crew, err error) {
if err = models.CrewUpdatePermission(token); err != nil {
return
}
Expand All @@ -88,7 +91,7 @@ func CrewUpdate(ctx context.Context, i *models.CrewUpdate, token *vcapool.Access
if crew.AspSelection == "selected" && match < len(strings) && strings[match] == i.AspSelection {
RoleHistoryDelete(ctx, &models.RoleHistoryRequest{CrewID: i.ID, Confirmed: false}, token)
}
if !token.Roles.Validate("employee;admin") {
if !token.Roles.Validate("admin;employee;pool_employee") {
if err = CrewsCollection.UpdateOne(ctx, filter, vmdb.UpdateSet(i.ToCrewUpdateASP()), &result); err != nil {
return
}
Expand All @@ -97,18 +100,17 @@ func CrewUpdate(ctx context.Context, i *models.CrewUpdate, token *vcapool.Access
return
}
}
if crew.Email != i.Email || crew.Name != i.Name {
if crew.Email != i.Email || crew.Name != i.Name || crew.OrganisationID != i.OrganisationID {
filter := bson.D{{Key: "crew_id", Value: i.ID}}
update := bson.D{{Key: "email", Value: i.Email}, {Key: "name", Value: i.Name}}
update := bson.D{{Key: "email", Value: i.Email}, {Key: "name", Value: i.Name}, {Key: "organisation_id", Value: i.OrganisationID}}
if err = UserCrewCollection.UpdateMany(ctx, filter, vmdb.UpdateSet(update)); err != nil {
return
}

}
return
}

func CrewUpdateAspSelection(ctx context.Context, i *models.CrewParam, value string, token *vcapool.AccessToken) (result *models.Crew, err error) {
func CrewUpdateAspSelection(ctx context.Context, i *models.CrewParam, value string, token *models.AccessToken) (result *models.Crew, err error) {
if err = models.CrewUpdatePermission(token); err != nil {
return
}
Expand All @@ -124,7 +126,7 @@ func CrewUpdateAspSelection(ctx context.Context, i *models.CrewParam, value stri
return
}

func CrewDelete(ctx context.Context, i *models.CrewParam, token *vcapool.AccessToken) (err error) {
func CrewDelete(ctx context.Context, i *models.CrewParam, token *models.AccessToken) (err error) {
if err = models.CrewPermission(token); err != nil {
return
}
Expand Down
5 changes: 3 additions & 2 deletions dao/defaults.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package dao

import (
"pool-backend/models"

"github.com/Viva-con-Agua/vcago"
"github.com/Viva-con-Agua/vcapool"
)

type Check struct {
Expand All @@ -17,7 +18,7 @@ func (i *Check) Return() error {
return i.Error
}

func (i *Check) ASP(token *vcapool.AccessToken) *Check {
func (i *Check) ASP(token *models.AccessToken) *Check {
if !token.PoolRoles.Validate("finance;network;education;") {
i.Error = vcago.NewPermissionDenied("permission_denied", nil)
}
Expand Down
Loading
Loading