Skip to content

Commit

Permalink
DOSSIER_ELEVE: Add own_classes filter for ProEco export
Browse files Browse the repository at this point in the history
  • Loading branch information
Supermanu committed Oct 14, 2022
1 parent 202adbf commit 5a939b3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
8 changes: 5 additions & 3 deletions assets/dossier_eleve/askExportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,11 @@ export default {
},
exportProEco: function () {
const export_type = this.tabIndex == 0 && this.$store.state.settings.enable_disciplinary_council ? "council" : "retenue";
window.open(
`/dossier_eleve/get_proeco_sanction/${export_type}/${this.date_from}/${this.date_to}/`
);
let url = `/dossier_eleve/get_proeco_sanction/${export_type}/${this.date_from}/${this.date_to}/`;
if (export_type === "retenue") {
url += `${this.ownClass}/`;
}
window.open(url);
}
},
mounted: function () {
Expand Down
11 changes: 10 additions & 1 deletion dossier_eleve/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@
urlpatterns += router.urls

if "proeco" in settings.INSTALLED_APPS:
urlpatterns += path('get_proeco_sanction/<export_type>/<date_from>/<date_to>/', views.ExportStudentToProEco.as_view()),
urlpatterns += [
path(
"get_proeco_sanction/<export_type>/<date_from>/<date_to>/<own_classes>/",
views.ExportStudentToProEco.as_view()
),
path(
"get_proeco_sanction/<export_type>/<date_from>/<date_to>/",
views.ExportStudentToProEco.as_view()
),
]
13 changes: 12 additions & 1 deletion dossier_eleve/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,17 +842,28 @@ def post(self, request, format=None):
from proeco.views import ExportStudentSelectionAPI

class ExportStudentToProEco(ExportStudentSelectionAPI):
def _get_student_list(self, request, kwargs):
def _get_student_list(self, request, kwargs, own_classes="false"):
date_from = kwargs["date_from"]
date_to = kwargs["date_to"]
export_type = kwargs["export_type"]
own_classes = (kwargs["own_classes"] if "own_classes" in kwargs else own_classes) == "true"

sanctions = CasEleve.objects.filter(
student__isnull=False,
sanction_decision__isnull=False,
sanction_faite=False,
)

if own_classes:
classes = get_classes(
teaching=get_settings().teachings.all(),
check_access=True,
user=self.request.user,
tenure_class_only=False,
educ_by_years=False
)
sanctions.filter(student__classe__in=list(classes))

if export_type == "council":
sanctions = sanctions.filter(
datetime_conseil__gte=date_from,
Expand Down

0 comments on commit 5a939b3

Please sign in to comment.