Skip to content

Commit

Permalink
Merge pull request #671 from ricardorcr/activeLessonPeriodInquiryNoti…
Browse files Browse the repository at this point in the history
…fication

Checking if there is an active lesson period to prompt inquiry FIST-796 #resolve
  • Loading branch information
ricardorcr authored Aug 30, 2019
2 parents 793f937 + 17194b2 commit ff66d3f
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.fenixedu.academic.domain.Department;
import org.fenixedu.academic.domain.ExecutionSemester;
import org.fenixedu.academic.domain.ExecutionYear;
import org.fenixedu.academic.domain.OccupationPeriodType;
import org.fenixedu.academic.domain.Person;
import org.fenixedu.academic.domain.accounting.Event;
import org.fenixedu.academic.domain.accounting.events.AdministrativeOfficeFeeEvent;
Expand All @@ -41,6 +42,7 @@
import org.fenixedu.bennu.core.security.Authenticate;
import org.fenixedu.bennu.struts.annotations.Mapping;

import org.joda.time.YearMonthDay;
import pt.ist.fenixWebFramework.renderers.components.HtmlLink;
import pt.ist.fenixWebFramework.servlets.filters.contentRewrite.GenericChecksumRewriter;
import pt.ist.fenixedu.contracts.domain.accessControl.ActiveEmployees;
Expand Down Expand Up @@ -114,9 +116,9 @@ private ActionForward handleSessionCreationAndForwardToFirstTimeCycleInquiry(Htt
}

private boolean isStudentAndHasFirstTimeCycleInquiryToRespond(User userView) {
if (RoleType.STUDENT.isMember(userView)) {
if (userView.getPerson() != null && userView.getPerson().getStudent() != null) {
final Student student = userView.getPerson().getStudent();
return student != null && InquiryStudentCycleAnswer.hasFirstTimeCycleInquiryToRespond(student);
return hasActiveClassPeriod(student) && InquiryStudentCycleAnswer.hasFirstTimeCycleInquiryToRespond(student);
}
return false;
}
Expand Down Expand Up @@ -163,9 +165,18 @@ private ActionForward handlePartyContactValidationRequests(HttpServletRequest re

private boolean hasMissingRAIDESInformation(User userView) {
return userView.getPerson() != null && userView.getPerson().getStudent() != null
&& hasActiveClassPeriod(userView.getPerson().getStudent())
&& userView.getPerson().getStudent().hasAnyMissingPersonalInformation();
}

private boolean hasActiveClassPeriod(final Student student) {
final ExecutionYear currentYear = ExecutionYear.readCurrentExecutionYear();
final YearMonthDay currentDay = new YearMonthDay();
return student.getActiveRegistrationStream()
.flatMap(r -> r.getDegree().getExecutionDegreesForExecutionYear(currentYear).stream())
.anyMatch(ed -> ed.getPeriods(OccupationPeriodType.LESSONS).anyMatch(op -> op.nestedOccupationPeriodsContainsDay(currentDay)));
}

private boolean hasPendingPartyContactValidationRequests(User userView) {
final Person person = userView.getPerson();
return person.hasPendingPartyContacts() && person.getCanValidateContacts();
Expand Down

0 comments on commit ff66d3f

Please sign in to comment.