Commit a07b3e5c authored by didonet's avatar didonet

Shows only valid transcript in the student grades.

parent 87674752
......@@ -30,6 +30,8 @@ public class Configuration {
@Autowired
public transient MailSender mailTemplate;
public static String REGISTRATION_PERIOD_OPEN = "registration.period.open";
public static String COORDINATOR_NAME = "coordinator.name";
public static String MASTER_COURSE_NAME = "master.course.name";
public static String PHD_COURSE_NAME = "phd.course.name";
......
......@@ -67,9 +67,18 @@ public class Transcript {
return entityManager().createNativeQuery("select * from transcript a, person b, registration c where a.student = c.id and c.student=b.id order by b.name",Transcript.class).getResultList();
}
public static List<Transcript> findTranscriptByRegInYearAndPeriodOrder(Registration r) {
return entityManager().createNativeQuery("select * from transcript t, section_pos sp" +
" where t.student = "+r.getId()+" and t.transcript_section = sp.id order by sp.section_year, sp.period",Transcript.class).getResultList();
public static List<Transcript> findTranscriptByRegInYearAndPeriodOrder(Registration r, Boolean onlyValidTranscripts) {
String sql = "select * from transcript t, section_pos sp" +
" where t.student = "+r.getId()+" and t.transcript_section = sp.id ";
if (onlyValidTranscripts)
sql = sql +
" and not (t.situation is null or t.situation = '"+SituationTranscript.Nulo+"' or t.situation = '"+SituationTranscript.Pendente+"' " +
" or t.situation = '"+SituationTranscript.Cancelado+"' " +
" or t.situation = '"+SituationTranscript.Trancado+"' " +
" )";
sql = sql +"order by sp.section_year, sp.period";
return entityManager().createNativeQuery(sql,Transcript.class).getResultList();
}
public static Object findTranscriptByYearOrProfessorOrAll(String year, String professor) {
......@@ -110,7 +119,7 @@ public class Transcript {
Paragraph p;
Student student = reg.getStudent();
List<Transcript> t = findTranscriptByRegInYearAndPeriodOrder(reg);
List<Transcript> t = findTranscriptByRegInYearAndPeriodOrder(reg,true);
//String gender = (student.getGender() == GenderKind.M) ? "o" : "a";
......@@ -243,7 +252,7 @@ public class Transcript {
String str;
Student student = reg.getStudent();
List<Transcript> t = findTranscriptByRegInYearAndPeriodOrder(reg);
List<Transcript> t = findTranscriptByRegInYearAndPeriodOrder(reg,true);
//String gender = (student.getGender() == GenderKind.M) ? "o" : "a";
......
......@@ -158,7 +158,7 @@ public class RegistrationController {
Registration reg = Registration.findRegistration(new Long(id));
model.addAttribute("registration", Registration.findRegistration(reg.getId()));
model.addAttribute("alltranscripts",Transcript.findTranscriptByRegInYearAndPeriodOrder(reg));
model.addAttribute("alltranscripts",Transcript.findTranscriptByRegInYearAndPeriodOrder(reg,false));
model.addAttribute("grants",StudentGrant.findGrantsPerRegistration(reg.getId()));
model.addAttribute("committees",Committee.findCommitteesPerRegistration(reg.getId()));
return "registrations/registrationoverview";
......
......@@ -35,6 +35,7 @@ public class RegistrationRequestController {
@RequestMapping(method = RequestMethod.POST)
public String create(@Valid RegistrationRequest regRequest, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
if (!regRequest.getIsWritingThesis() &&
regRequest.getSectionPos1() == null && regRequest.getSectionPos2() == null && regRequest.getSectionPos3() == null &&
regRequest.getSectionPos5() == null && regRequest.getSectionPos5() == null) {
......@@ -112,6 +113,9 @@ public class RegistrationRequestController {
@RequestMapping(params = "newrequest", method = RequestMethod.GET)
public String newRequestForm(Model uiModel) {
if (! new Boolean (Configuration.findConfigValueByName(Configuration.REGISTRATION_PERIOD_OPEN)) )
return "Request out of the valid period";
uiModel.addAttribute("registrationrequest", new RegistrationRequest());
addDateTimeFormatPatterns(uiModel);
return "registrationrequests/request"; // maps to create.jspx
......
......@@ -77,7 +77,7 @@ public class TranscriptController {
public String registrationsStatementList(@RequestParam(value = "registration", required = true) String id,
Model model) {
Registration reg = Registration.findRegistration(new Long(id));
model.addAttribute("transcripts", Transcript.findTranscriptByRegInYearAndPeriodOrder(reg));
model.addAttribute("transcripts", Transcript.findTranscriptByRegInYearAndPeriodOrder(reg,false));
return "transcripts/liststudentsstatement";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment