Example #1
0
class DeleteAttribution(AttributionBaseViewMixin, AjaxTemplateMixin,
                        DeleteView):
    rules = [
        lambda luy, person: perms.is_eligible_to_manage_charge_repartition(
            luy, person) or perms.is_eligible_to_manage_attributions(
                luy, person)
    ]
    model = AttributionNew
    template_name = "attribution/learning_unit/remove_charge_repartition_confirmation_inner.html"
    pk_url_kwarg = "attribution_id"

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context["attribution"] = self.attribution
        return context

    def delete(self, request, *args, **kwargs):
        success_message = self.get_success_message()
        response = super().delete(request, *args, **kwargs)
        if success_message:
            messages.success(self.request, success_message)
        return response

    def get_success_message(self):
        return _("Attribution removed for %(tutor)s (%(function)s)") % \
               {"tutor": self.attribution.tutor.person,
                "function": _(self.attribution.get_function_display())}
Example #2
0
def learning_unit_attributions(request, learning_unit_year_id):
    context = get_common_context_learning_unit_year(learning_unit_year_id, request.user.person)

    context['attributions'] = attribution_charge_new.find_attributions_with_charges(learning_unit_year_id)
    context["can_manage_charge_repartition"] = business_perms.is_eligible_to_manage_charge_repartition(
        context["learning_unit_year"], request.user.person
    )
    context["can_manage_attribution"] = business_perms.is_eligible_to_manage_attributions(
        context["learning_unit_year"], request.user.person
    )
    warning_msgs = get_charge_repartition_warning_messages(context["learning_unit_year"].learning_container_year)
    display_warning_messages(request, warning_msgs)
    return render(request, "learning_unit/attributions.html", context)
Example #3
0
def learning_unit_attributions(request, learning_unit_year_id):
    person = get_object_or_404(Person, user=request.user)
    context = get_common_context_learning_unit_year(learning_unit_year_id,
                                                    person)
    context[
        'attributions'] = attribution_charge_new.find_attributions_with_charges(
            learning_unit_year_id)
    context["can_manage_charge_repartition"] = \
        business_perms.is_eligible_to_manage_charge_repartition(context["learning_unit_year"], person)
    context["can_manage_attribution"] = \
        business_perms.is_eligible_to_manage_attributions(context["learning_unit_year"], person)
    context['experimental_phase'] = True

    warning_msgs = get_charge_repartition_warning_messages(
        context["learning_unit_year"].learning_container_year)
    display_warning_messages(request, warning_msgs)
    return render(request, "learning_unit/attributions.html", context)