<commit_before>package in.ac.amu.zhcet.controller.dean;

import in.ac.amu.zhcet.data.model.Department;
import in.ac.amu.zhcet.service.DepartmentService;
import in.ac.amu.zhcet.service.UserService;
import in.ac.amu.zhcet.utils.exception.DuplicateException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Controller
public class DeanController {

    private final UserService userService;
    private final DepartmentService departmentService;

    @Autowired
    public DeanController(UserService userService, DepartmentService departmentService) {
        this.userService = userService;
        this.departmentService = departmentService;
    }

    @GetMapping("/dean")
    public String deanAdmin(Model model, WebRequest webRequest) {
        model.addAttribute("page_title", "Administration Panel");
        model.addAttribute("page_subtitle", "Dean Administration Panel");
        model.addAttribute("page_description", "Register Students and Faculty, manage roles and users");

        if (!model.containsAttribute("faculty_success"))
            webRequest.removeAttribute("confirmFacultyRegistration", RequestAttributes.SCOPE_SESSION);

        if (!model.containsAttribute("student_success"))
            webRequest.removeAttribute("confirmStudentRegistration", RequestAttributes.SCOPE_SESSION);

        model.addAttribute("users", userService.getAll());
        if (!model.containsAttribute("department"))
            model.addAttribute("department", new Department());
        model.addAttribute("departments", departmentService.findAll());

        return "dean/admin";
    }

    @PostMapping("/dean/departments/add")
    public String addDepartment(@Valid Department department, BindingResult bindingResult, RedirectAttributes redirectAttributes) {

        if (bindingResult.hasErrors()) {
            redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.department", bindingResult);
            redirectAttributes.addFlashAttribute("department", department);
        } else {
            try {
                departmentService.addDepartment(department);
                redirectAttributes.addFlashAttribute("dept_success", true);<commit_msg>fix: Student registration modal not showing<commit_after>package in.ac.amu.zhcet.controller.dean;

import in.ac.amu.zhcet.data.model.Department;
import in.ac.amu.zhcet.service.DepartmentService;
import in.ac.amu.zhcet.service.UserService;
import in.ac.amu.zhcet.utils.exception.DuplicateException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Controller
public class DeanController {

    private final UserService userService;
    private final DepartmentService departmentService;

    @Autowired
    public DeanController(UserService userService, DepartmentService departmentService) {
        this.userService = userService;
        this.departmentService = departmentService;
    }

    @GetMapping("/dean")
    public String deanAdmin(Model model, WebRequest webRequest) {
        model.addAttribute("page_title", "Administration Panel");
        model.addAttribute("page_subtitle", "Dean Administration Panel");
        model.addAttribute("page_description", "Register Students and Faculty, manage roles and users");

        if (!model.containsAttribute("faculty_success"))
            webRequest.removeAttribute("confirmFacultyRegistration", RequestAttributes.SCOPE_SESSION);

        if (!model.containsAttribute("students_success"))
            webRequest.removeAttribute("confirmStudentRegistration", RequestAttributes.SCOPE_SESSION);

        model.addAttribute("users", userService.getAll());
        if (!model.containsAttribute("department"))
            model.addAttribute("department", new Department());
        model.addAttribute("departments", departmentService.findAll());

        return "dean/admin";
    }

    @PostMapping("/dean/departments/add")
    public String addDepartment(@Valid Department department, BindingResult bindingResult, RedirectAttributes redirectAttributes) {

        if (bindingResult.hasErrors()) {
            redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.department", bindingResult);
            redirectAttributes.addFlashAttribute("department", department);
        } else {
            try {
                departmentService.addDepartment(department);
                redirectAttributes.addFlashAttribute("dept_success", true);
{'fraction_non_alphanumeric': 0.09937555753791258, 'fraction_numerical': 0.0010704727921498661, 'mean_word_length': 4.572564612326044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4823654', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1395, 'n_words': 248}