Skip to content

Commit

Permalink
Merge pull request #5648 from deNBI/fix/queryset_group
Browse files Browse the repository at this point in the history
fix(Project Overview): Prevent of sending bad request for unapproved projects
  • Loading branch information
dweinholz authored Apr 26, 2023
2 parents f722507 + 057cb04 commit d549774
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
2 changes: 2 additions & 0 deletions src/app/api-connector/group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export class GroupService {
}

getGroupApplications(group: number | string): Observable<any> {
console.log(group);

return this.http.get(`${ApiSettings.getApiBaseURL()}projects/${group}/applications/`, {
withCredentials: true,
});
Expand Down
4 changes: 4 additions & 0 deletions src/app/applications/application.model/application.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ export class Application {
} else return 0;
}

public isApproved(): boolean {
return this.project_application_statuses.includes(Application_States.APPROVED);
}

public setFlavorInFlavors(flavor_param: Flavor, counter: number): void {
const idx: number = this.flavors.findIndex((fl: Flavor): boolean => fl.name === flavor_param.name);
if (idx !== -1) {
Expand Down
54 changes: 29 additions & 25 deletions src/app/projectmanagement/overview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,32 +684,36 @@ export class OverviewComponent extends ApplicationBaseClassComponent implements
* Get all user applications for a project.
*/
getUserProjectApplications(): void {
this.memberApplicationsLoaded = false;
this.subscription.add(
this.groupService
.getGroupApplications(this.project_application.project_application_perun_id)
.subscribe((applications: any): void => {
const newProjectApplications: ProjectMemberApplication[] = [];
if (applications.length === 0) {
this.project_application.project_application_member_applications = [];
if (this.project_application.isApproved() && this.project_application.project_application_perun_id) {
this.memberApplicationsLoaded = false;
this.subscription.add(
this.groupService
.getGroupApplications(this.project_application.project_application_perun_id)
.subscribe((applications: any): void => {
const newProjectApplications: ProjectMemberApplication[] = [];
if (applications.length === 0) {
this.project_application.project_application_member_applications = [];

this.memberApplicationsLoaded = true;
}
for (const application of applications) {
const dateApplicationCreated: moment.Moment = moment(application['createdAt'], 'YYYY-MM-DD HH:mm:ss.SSS');
const membername: string = application['displayName'];

const newMemberApplication: ProjectMemberApplication = new ProjectMemberApplication(
application['id'],
membername,
`${dateApplicationCreated.date()}.${dateApplicationCreated.month() + 1}.${dateApplicationCreated.year()}`,
);
newProjectApplications.push(newMemberApplication);
this.project_application.project_application_member_applications = newProjectApplications;
this.memberApplicationsLoaded = true;
}
}),
);
this.memberApplicationsLoaded = true;
}
for (const application of applications) {
const dateApplicationCreated: moment.Moment = moment(application['createdAt'], 'YYYY-MM-DD HH:mm:ss.SSS');
const membername: string = application['displayName'];

const newMemberApplication: ProjectMemberApplication = new ProjectMemberApplication(
application['id'],
membername,
`${dateApplicationCreated.date()}.${
dateApplicationCreated.month() + 1
}.${dateApplicationCreated.year()}`,
);
newProjectApplications.push(newMemberApplication);
this.project_application.project_application_member_applications = newProjectApplications;
this.memberApplicationsLoaded = true;
}
}),
);
}
}

setSupportMails(project: Application): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IResponseTemplate } from '../../../../api-connector/response-template';
templateUrl: './project-email-modal.component.html',
styleUrls: ['./projext-email-modal.component.scss'],
})
export class ProjectEmailModalComponent implements OnDestroy, OnInit {
export class ProjectEmailModalComponent implements OnInit, OnDestroy {
// currently only for vo
@Input() selectedProjects: Application[];
emailAdminsOnly: boolean;
Expand All @@ -20,6 +20,7 @@ export class ProjectEmailModalComponent implements OnDestroy, OnInit {
emailText: string;
templates: string[];


public event: EventEmitter<boolean> = new EventEmitter();

constructor(public bsModalRef: BsModalRef, private voService: VoService) {
Expand All @@ -43,6 +44,7 @@ export class ProjectEmailModalComponent implements OnDestroy, OnInit {
.sendMailToProjects(project_ids, this.emailSubject, this.emailText, this.emailAdminsOnly, this.emailReply)
.subscribe(
(res: IResponseTemplate) => {

this.event.emit(res.value as boolean);
},
() => {
Expand Down

0 comments on commit d549774

Please sign in to comment.