Black update

This commit is contained in:
Skia 2021-09-26 04:20:49 +02:00
parent 406380e4f1
commit a3158253a7
7 changed files with 33 additions and 35 deletions

View File

@ -496,7 +496,7 @@ class OperationCreateView(CanCreateMixin, CreateView):
return ret
def get_context_data(self, **kwargs):
""" Add journal to the context """
"""Add journal to the context"""
kwargs = super(OperationCreateView, self).get_context_data(**kwargs)
if self.journal:
kwargs["object"] = self.journal
@ -514,7 +514,7 @@ class OperationEditView(CanEditMixin, UpdateView):
template_name = "accounting/operation_edit.jinja"
def get_context_data(self, **kwargs):
""" Add journal to the context """
"""Add journal to the context"""
kwargs = super(OperationEditView, self).get_context_data(**kwargs)
kwargs["object"] = self.object.journal
return kwargs
@ -735,7 +735,7 @@ class JournalNatureStatementView(JournalTabsMixin, CanViewMixin, DetailView):
return statement
def get_context_data(self, **kwargs):
""" Add infos to the context """
"""Add infos to the context"""
kwargs = super(JournalNatureStatementView, self).get_context_data(**kwargs)
kwargs["statement"] = self.big_statement()
return kwargs
@ -774,7 +774,7 @@ class JournalPersonStatementView(JournalTabsMixin, CanViewMixin, DetailView):
return sum(self.statement(movement_type).values())
def get_context_data(self, **kwargs):
""" Add journal to the context """
"""Add journal to the context"""
kwargs = super(JournalPersonStatementView, self).get_context_data(**kwargs)
kwargs["credit_statement"] = self.statement("CREDIT")
kwargs["debit_statement"] = self.statement("DEBIT")
@ -804,7 +804,7 @@ class JournalAccountingStatementView(JournalTabsMixin, CanViewMixin, DetailView)
return statement
def get_context_data(self, **kwargs):
""" Add journal to the context """
"""Add journal to the context"""
kwargs = super(JournalAccountingStatementView, self).get_context_data(**kwargs)
kwargs["statement"] = self.statement()
return kwargs

View File

@ -534,7 +534,7 @@ class WeekmailEditView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, UpdateVi
return super(WeekmailEditView, self).get(request, *args, **kwargs)
def get_context_data(self, **kwargs):
"""Add orphan articles """
"""Add orphan articles"""
kwargs = super(WeekmailEditView, self).get_context_data(**kwargs)
kwargs["orphans"] = WeekmailArticle.objects.filter(weekmail=None)
return kwargs

View File

@ -74,22 +74,20 @@ class CounterTest(TestCase):
},
)
response = self.client.post(location, {"action": "code", "code": "BARB"})
response = self.client.post(location, {"action": "add_product", "product_id": "4"})
response = self.client.post(location, {"action": "del_product", "product_id": "4"})
response = self.client.post(
location, {"action": "add_product", "product_id": "4"}
)
response = self.client.post(
location, {"action": "del_product", "product_id": "4"}
)
response = self.client.post(location, {"action": "code", "code": "2xdeco"})
response = self.client.post(location, {"action": "code", "code": "1xbarb"})
response = self.client.post(location, {"action": "code", "code": "fin"})
response_get = self.client.get(response.get("location"))
response_content = response_get.content.decode("utf-8")
self.assertTrue(
"<li>2 x Barbar"
in str(response_content)
)
self.assertTrue(
"<li>2 x Déconsigne Eco-cup"
in str(response_content)
)
self.assertTrue("<li>2 x Barbar" in str(response_content))
self.assertTrue("<li>2 x Déconsigne Eco-cup" in str(response_content))
self.assertTrue(
"<p>Client : Richard Batsbak - Nouveau montant : 3.60"
in str(response_content)

View File

@ -425,7 +425,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
return ret
def post(self, request, *args, **kwargs):
""" Handle the many possibilities of the post request """
"""Handle the many possibilities of the post request"""
self.object = self.get_object()
self.refill_form = None
if (self.object.type != "BAR" and not request.user.is_authenticated) or (
@ -621,7 +621,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
return True
def del_product(self, request):
""" Delete a product from the basket """
"""Delete a product from the basket"""
pid = str(request.POST["product_id"])
product = self.get_product(pid)
if pid in request.session["basket"]:
@ -663,7 +663,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
return self.render_to_response(context)
def finish(self, request):
""" Finish the click session, and validate the basket """
"""Finish the click session, and validate the basket"""
with transaction.atomic():
request.session["last_basket"] = []
if self.sum_basket(request) > self.customer.amount:
@ -715,7 +715,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
)
def cancel(self, request):
""" Cancel the click session """
"""Cancel the click session"""
kwargs = {"counter_id": self.object.id}
request.session.pop("basket", None)
return HttpResponseRedirect(
@ -737,7 +737,7 @@ class CounterClick(CounterTabsMixin, CanViewMixin, DetailView):
raise PermissionDenied
def get_context_data(self, **kwargs):
""" Add customer to the context """
"""Add customer to the context"""
kwargs = super(CounterClick, self).get_context_data(**kwargs)
kwargs["products"] = self.object.products.select_related("product_type")
kwargs["categories"] = {}
@ -1391,7 +1391,7 @@ class CounterLastOperationsView(CounterTabsMixin, CanViewMixin, DetailView):
)
def get_context_data(self, **kwargs):
"""Add form to the context """
"""Add form to the context"""
kwargs = super(CounterLastOperationsView, self).get_context_data(**kwargs)
threshold = timezone.now() - timedelta(
minutes=settings.SITH_LAST_OPERATIONS_LIMIT
@ -1453,7 +1453,7 @@ class CounterCashSummaryView(CounterTabsMixin, CanViewMixin, DetailView):
return reverse_lazy("counter:details", kwargs={"counter_id": self.object.id})
def get_context_data(self, **kwargs):
""" Add form to the context """
"""Add form to the context"""
kwargs = super(CounterCashSummaryView, self).get_context_data(**kwargs)
kwargs["form"] = self.form
return kwargs
@ -1479,7 +1479,7 @@ class CounterStatView(DetailView, CounterAdminMixin):
template_name = "counter/stats.jinja"
def get_context_data(self, **kwargs):
""" Add stats to the context """
"""Add stats to the context"""
from django.db.models import Sum, Case, When, F, DecimalField
kwargs = super(CounterStatView, self).get_context_data(**kwargs)
@ -1609,7 +1609,7 @@ class CashSummaryListView(CounterAdminTabsMixin, CounterAdminMixin, ListView):
paginate_by = settings.SITH_COUNTER_CASH_SUMMARY_LENGTH
def get_context_data(self, **kwargs):
""" Add sums to the context """
"""Add sums to the context"""
kwargs = super(CashSummaryListView, self).get_context_data(**kwargs)
form = CashSummaryFormBase(self.request.GET)
kwargs["form"] = form
@ -1660,7 +1660,7 @@ class InvoiceCallView(CounterAdminTabsMixin, CounterAdminMixin, TemplateView):
current_tab = "invoices_call"
def get_context_data(self, **kwargs):
""" Add sums to the context """
"""Add sums to the context"""
kwargs = super(InvoiceCallView, self).get_context_data(**kwargs)
kwargs["months"] = Selling.objects.datetimes("date", "month", order="DESC")
start_date = None

View File

@ -82,7 +82,7 @@ class EbouticMain(TemplateView):
return self.render_to_response(self.get_context_data(**kwargs))
def add_product(self, request):
""" Add a product to the basket """
"""Add a product to the basket"""
try:
p = self.object.products.filter(id=int(request.POST["product_id"])).first()
if not p.buying_groups.exists():
@ -95,7 +95,7 @@ class EbouticMain(TemplateView):
pass
def del_product(self, request):
""" Delete a product from the basket """
"""Delete a product from the basket"""
try:
p = self.object.products.filter(id=int(request.POST["product_id"])).first()
self.basket.del_product(p)

View File

@ -49,7 +49,7 @@ class LimitedCheckboxField(forms.ModelMultipleChoiceField):
class CandidateForm(forms.ModelForm):
""" Form to candidate """
"""Form to candidate"""
class Meta:
model = Candidature
@ -95,7 +95,7 @@ class VoteForm(forms.Form):
class RoleForm(forms.ModelForm):
""" Form for creating a role """
"""Form for creating a role"""
class Meta:
model = Role
@ -261,7 +261,7 @@ class ElectionDetailView(CanViewMixin, DetailView):
return r
def get_context_data(self, **kwargs):
""" Add additionnal data to the template """
"""Add additionnal data to the template"""
kwargs = super(ElectionDetailView, self).get_context_data(**kwargs)
kwargs["election_form"] = VoteForm(self.object, self.request.user)
kwargs["election_results"] = self.object.results
@ -322,7 +322,7 @@ class VoteFormView(CanCreateMixin, FormView):
return reverse_lazy("election:detail", kwargs={"election_id": self.election.id})
def get_context_data(self, **kwargs):
""" Add additionnal data to the template """
"""Add additionnal data to the template"""
kwargs = super(VoteFormView, self).get_context_data(**kwargs)
kwargs["object"] = self.election
kwargs["election"] = self.election

View File

@ -52,7 +52,7 @@ class LaunderetteMainView(TemplateView):
template_name = "launderette/launderette_main.jinja"
def get_context_data(self, **kwargs):
""" Add page to the context """
"""Add page to the context"""
kwargs = super(LaunderetteMainView, self).get_context_data(**kwargs)
kwargs["page"] = Page.objects.filter(name="launderette").first()
return kwargs
@ -142,7 +142,7 @@ class LaunderetteBookView(CanViewMixin, DetailView):
currentDate += delta
def get_context_data(self, **kwargs):
""" Add page to the context """
"""Add page to the context"""
kwargs = super(LaunderetteBookView, self).get_context_data(**kwargs)
kwargs["planning"] = OrderedDict()
kwargs["slot_type"] = self.slot_type
@ -481,7 +481,7 @@ class LaunderetteClickView(CanEditMixin, DetailView, BaseFormView):
return super(LaunderetteClickView, self).get(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
""" Handle the many possibilities of the post request """
"""Handle the many possibilities of the post request"""
self.object = self.get_object()
self.customer = Customer.objects.filter(user__id=self.kwargs["user_id"]).first()
self.subscriber = self.customer.user