Merge branch 'newbie' into 'master'

Reset comptes COF

See merge request klub-dev-ens/gestioCOF!479
This commit is contained in:
Ludovic Stephan 2021-01-07 09:32:33 +01:00
commit 33319cfe76
4 changed files with 34 additions and 0 deletions

View file

@ -115,6 +115,7 @@
<ul>
<li><a href="{% url "utile_cof" %}">Liens utiles du COF</a></li>
<li><a href="{% url "utile_bda" %}">Liens utiles BdA</a></li>
<li><a href="{% url "reset_comptes" %}">Remise à zéro adhérents COF</a></li>
</ul>
</div>
</div>

View file

@ -0,0 +1,14 @@
{% extends "base_title.html" %}
{% block realcontent %}
<h2>Remise à zéro des membres COF</h2>
{% if is_done%}
<p> {{nb_adherents}} compte{{ nb_adherents|pluralize }} désinscrit{{ nb_adherents|pluralize }} du COF.</p>
{% else%}
<div class="alert alert-danger"> ATTENTION : Cette action est irréversible. </div>
<p> Voulez-vous vraiment remettre à zéro le statut COF de tous les membres actuels ?</p>
<form action="" method="POST">
<input type='submit' value="Confirmer" class="btn btn-primary pull-right">{% csrf_token %}
</form>
{% endif %}
{% endblock %}

View file

@ -82,6 +82,7 @@ urlpatterns = [
# Misc
# -----
path("", views.HomeView.as_view(), name="home"),
path("reset_comptes/", views.ResetComptes.as_view(), name="reset_comptes"),
path(
"user/autocomplete",
views.UserAutocompleteView.as_view(),

View file

@ -79,6 +79,24 @@ class HomeView(LoginRequiredMixin, TemplateView):
return context
class ResetComptes(BuroRequiredMixin, TemplateView):
template_name = "gestioncof/reset_comptes.html"
def post(self, request):
nb_adherents = CofProfile.objects.filter(is_cof=True).count()
CofProfile.objects.update(
is_cof=False,
mailing_cof=False,
mailing_bda=False,
mailing_bda_revente=False,
mailing_unernestaparis=False,
)
context = super().get_context_data()
context["is_done"] = True
context["nb_adherents"] = nb_adherents
return render(request, self.template_name, context)
def login(request):
if request.user.is_authenticated:
return redirect("home")