🚨 format python code using black

This commit is contained in:
Nikolai R Kristiansen committed 2021-10-27 19:22:25 +02:00
1 parent 9c4a5b3d84
commit a052397990
24 files changed
+643 -407

No files matched your search

+16 -17
View File
@@ -10,23 +10,23 @@ class OrderForm(forms.ModelForm):
customer_name = forms.CharField(required=False)
def clean(self):
if self.cleaned_data['customer'] is None and self.cleaned_data['customer_name'] != "Ekstern":
if self.cleaned_data["customer"] is None and self.cleaned_data["customer_name"] != "Ekstern":
raise forms.ValidationError(_("Du har ikke valgt hvem som skal kjøpe."))
return self.cleaned_data
def clean_customer(self):
if self.cleaned_data['customer'] is None:
return self.cleaned_data['customer']
if self.cleaned_data["customer"] is None:
return self.cleaned_data["customer"]
if self.cleaned_data['customer'].profile.balance <= 0:
if self.cleaned_data["customer"].profile.balance <= 0:
raise forms.ValidationError(_("Du har negativ saldo og kan ikke kjøpe noe."))
return self.cleaned_data['customer']
return self.cleaned_data["customer"]
class Meta:
model = Order
fields = ('customer',)
fields = ("customer",)
class OrderLineForm(forms.Form):
@@ -37,10 +37,9 @@ class OrderLineForm(forms.Form):
class DepositForm(forms.ModelForm):
class Meta:
model = Transaction
fields = ['user', 'amount']
fields = ["user", "amount"]
class SimpleCreateUserForm(forms.Form):
@@ -50,15 +49,15 @@ class SimpleCreateUserForm(forms.Form):
facebook_username = forms.CharField(required=False, label="Facebook-brukernavn")
def _get_facebook_url(self):
if self.cleaned_data['facebook_username'] == "":
if self.cleaned_data["facebook_username"] == "":
return ""
return "https://graph.facebook.com/{0}/picture".format(self.cleaned_data['facebook_username'])
return "https://graph.facebook.com/{0}/picture".format(self.cleaned_data["facebook_username"])
def save(self, commit=True):
username = format_username(self.cleaned_data['first_name'], self.cleaned_data['last_name'])
user = User.objects.create_user(username, email=self.cleaned_data['email'])
user.first_name = self.cleaned_data['first_name']
user.last_name = self.cleaned_data['last_name']
def save(self, commit=True):
username = format_username(self.cleaned_data["first_name"], self.cleaned_data["last_name"])
user = User.objects.create_user(username, email=self.cleaned_data["email"])
user.first_name = self.cleaned_data["first_name"]
user.last_name = self.cleaned_data["last_name"]
profile = UserProfile.objects.create(user=user)
profile.image = self._get_facebook_url()
@@ -76,11 +75,11 @@ class InventoryTransactionForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
# Only show active products
super(InventoryTransactionForm, self).__init__(*args, **kwargs)
self.fields['product'].queryset = Product.objects.filter(active=True)
self.fields["product"].queryset = Product.objects.filter(active=True)
class Meta:
model = InventoryTransaction
fields = ['product', 'amount', 'unit_price', 'comment']
fields = ["product", "amount", "unit_price", "comment"]
class DateRangeForm(forms.Form):