From c9098fa2cf10aefbfa4bbc4add1ccc269cc49023 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 19 Jul 2022 11:47:03 +0200 Subject: [PATCH 1/7] fix: Add Contributions to User --- .../entity/0039-contributions_table/User.ts | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 database/entity/0039-contributions_table/User.ts diff --git a/database/entity/0039-contributions_table/User.ts b/database/entity/0039-contributions_table/User.ts new file mode 100644 index 000000000..147ae6f6f --- /dev/null +++ b/database/entity/0039-contributions_table/User.ts @@ -0,0 +1,83 @@ +import { + BaseEntity, + Entity, + PrimaryGeneratedColumn, + Column, + DeleteDateColumn, + OneToMany, + JoinColumn, +} from 'typeorm' +import { Contribution } from '../Contribution' + +@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' }) +export class User extends BaseEntity { + @PrimaryGeneratedColumn('increment', { unsigned: true }) + id: number + + @Column({ name: 'public_key', type: 'binary', length: 32, default: null, nullable: true }) + pubKey: Buffer + + @Column({ name: 'privkey', type: 'binary', length: 80, default: null, nullable: true }) + privKey: Buffer + + @Column({ length: 255, unique: true, nullable: false, collation: 'utf8mb4_unicode_ci' }) + email: string + + @Column({ + name: 'first_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + firstName: string + + @Column({ + name: 'last_name', + length: 255, + nullable: true, + default: null, + collation: 'utf8mb4_unicode_ci', + }) + lastName: string + + @DeleteDateColumn() + deletedAt: Date | null + + @Column({ type: 'bigint', default: 0, unsigned: true }) + password: BigInt + + @Column({ name: 'email_hash', type: 'binary', length: 32, default: null, nullable: true }) + emailHash: Buffer + + @Column({ name: 'created', default: () => 'CURRENT_TIMESTAMP', nullable: false }) + createdAt: Date + + @Column({ name: 'email_checked', type: 'bool', nullable: false, default: false }) + emailChecked: boolean + + @Column({ length: 4, default: 'de', collation: 'utf8mb4_unicode_ci', nullable: false }) + language: string + + @Column({ name: 'is_admin', type: 'datetime', nullable: true, default: null }) + isAdmin: Date | null + + @Column({ name: 'referrer_id', type: 'int', unsigned: true, nullable: true, default: null }) + referrerId?: number | null + + @Column({ name: 'publisher_id', default: 0 }) + publisherId: number + + @Column({ + type: 'text', + name: 'passphrase', + collation: 'utf8mb4_unicode_ci', + nullable: true, + default: null, + }) + passphrase: string + + @OneToMany(() => Contribution, (contribution) => contribution.user) + @JoinColumn({ name: 'user_id' }) + contributions?: Contribution[] +} From 038a3c1a7cf6d818f27935a9e0c111f5ff03603a Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 20 Jul 2022 09:05:04 +0200 Subject: [PATCH 2/7] prepared for ContributionForm.spec.js --- .../components/Contributions/ContributionForm.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 44fa170b1..5b05957bb 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -6,6 +6,15 @@ const localVue = global.localVue describe('ContributionForm', () => { let wrapper + const propsData = { + value: { + id: null, + date: '', + memo: '', + amount: '', + }, + } + const mocks = { $t: jest.fn((t) => t), $d: jest.fn((d) => d), @@ -20,6 +29,7 @@ describe('ContributionForm', () => { return mount(ContributionForm, { localVue, mocks, + propsData, }) } From c8267cf77415fd48c5f9b79d3d890e09c5c4d5ab Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 20 Jul 2022 10:42:24 +0200 Subject: [PATCH 3/7] Add contributionDate to the Contribution object. --- backend/src/graphql/model/Contribution.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index 13c2d40d7..aa878990c 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -15,6 +15,7 @@ export class Contribution { this.deletedAt = contribution.deletedAt this.confirmedAt = contribution.confirmedAt this.confirmedBy = contribution.confirmedBy + this.contributionDate = contribution.contributionDate } @Field(() => Number) @@ -43,6 +44,9 @@ export class Contribution { @Field(() => Number, { nullable: true }) confirmedBy: number | null + + @Field(() => Date) + contributionDate: Date } @ObjectType() From 46553c02d6cae1498168fa850c06bcce3e15c0d5 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 20 Jul 2022 11:01:36 +0200 Subject: [PATCH 4/7] prepare math function maxGdd for Months when edit --- .../Contributions/ContributionForm.vue | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 8a52146a1..0b4cb3611 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -79,6 +79,10 @@ + {{ typeof this.$store.state.creation[2] }}, {{ typeof this.form.amount }}, + {{ typeof maxGddThisMonth }}({{ maxGddThisMonth }}) +
+ {{ isThisMonth }} From a87c5f70eed99e72a4a6f1057f703e27e75477a3 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 20 Jul 2022 12:01:45 +0200 Subject: [PATCH 5/7] add contributionDate for contribution list --- .../components/Contributions/ContributionForm.vue | 12 ++++-------- .../Contributions/ContributionListItem.vue | 7 +++++-- frontend/src/graphql/queries.js | 3 +++ frontend/src/pages/Community.vue | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 0b4cb3611..12714268e 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -74,15 +74,11 @@ - {{ id === null ? $t('contribution.submit') : $t('form.edit') }} + {{ value.id ? $t('form.edit') : $t('contribution.submit') }} - {{ typeof this.$store.state.creation[2] }}, {{ typeof this.form.amount }}, - {{ typeof maxGddThisMonth }}({{ maxGddThisMonth }}) -
- {{ isThisMonth }} diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 77c426668..edc9c4956 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -6,6 +6,7 @@