From 2155d46877033e28f19878e05b1bbaba07c233bb Mon Sep 17 00:00:00 2001 From: chirac Date: Sat, 2 Jul 2016 17:58:04 +0200 Subject: [PATCH] =?UTF-8?q?Fonction=20de=20cr=C3=A9ation=20et=20d'edition?= =?UTF-8?q?=20de=20factures=20parfaitement=20fonctionnelle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/__pycache__/admin.cpython-34.pyc | Bin 165 -> 1182 bytes cotisations/__pycache__/models.cpython-34.pyc | Bin 3640 -> 3591 bytes cotisations/__pycache__/views.cpython-34.pyc | Bin 1967 -> 2267 bytes cotisations/admin.py | 19 ++++++++++++- .../migrations/0002_remove_facture_article.py | 18 ++++++++++++ .../migrations/0003_auto_20160702_1448.py | 20 ++++++++++++++ .../migrations/0004_auto_20160702_1528.py | 24 ++++++++++++++++ .../migrations/0005_auto_20160702_1532.py | 19 +++++++++++++ .../migrations/0006_auto_20160702_1534.py | 24 ++++++++++++++++ .../migrations/0007_auto_20160702_1543.py | 26 ++++++++++++++++++ ...0002_remove_facture_article.cpython-34.pyc | Bin 0 -> 617 bytes .../0003_auto_20160702_1448.cpython-34.pyc | Bin 0 -> 817 bytes .../0004_auto_20160702_1528.cpython-34.pyc | Bin 0 -> 795 bytes .../0005_auto_20160702_1532.cpython-34.pyc | Bin 0 -> 707 bytes .../0006_auto_20160702_1534.cpython-34.pyc | Bin 0 -> 827 bytes .../0007_auto_20160702_1543.cpython-34.pyc | Bin 0 -> 843 bytes cotisations/models.py | 12 ++++---- .../templates/cotisations/facture.html | 2 +- cotisations/templates/cotisations/index.html | 18 ++++++------ cotisations/views.py | 16 +++++++++-- 20 files changed, 178 insertions(+), 20 deletions(-) create mode 100644 cotisations/migrations/0002_remove_facture_article.py create mode 100644 cotisations/migrations/0003_auto_20160702_1448.py create mode 100644 cotisations/migrations/0004_auto_20160702_1528.py create mode 100644 cotisations/migrations/0005_auto_20160702_1532.py create mode 100644 cotisations/migrations/0006_auto_20160702_1534.py create mode 100644 cotisations/migrations/0007_auto_20160702_1543.py create mode 100644 cotisations/migrations/__pycache__/0002_remove_facture_article.cpython-34.pyc create mode 100644 cotisations/migrations/__pycache__/0003_auto_20160702_1448.cpython-34.pyc create mode 100644 cotisations/migrations/__pycache__/0004_auto_20160702_1528.cpython-34.pyc create mode 100644 cotisations/migrations/__pycache__/0005_auto_20160702_1532.cpython-34.pyc create mode 100644 cotisations/migrations/__pycache__/0006_auto_20160702_1534.cpython-34.pyc create mode 100644 cotisations/migrations/__pycache__/0007_auto_20160702_1543.cpython-34.pyc diff --git a/cotisations/__pycache__/admin.cpython-34.pyc b/cotisations/__pycache__/admin.cpython-34.pyc index 0e4e22211de9a2103651dcc4eede17350d4405df..a11e97072093a160772afeec761c1a8b4ec63781 100644 GIT binary patch literal 1182 zcmbVMJ#X7E5IsuNhh^DKn<7QmY+7QVb5S@QlBq@k4+XRcib(`A^x;ra9eYjxOn*-{ zt_2EY=@01CJ4#NSq)RGUhr4@6@$ucszrs;)bi4jCwE%v=-o??M;#2=bBk;!{2PhcC z44AM$*pORL*bv)LaELh+4#W-=F2pXdbHPD4@C_F_AQ>z@xWQT<&V>uYGk~`T3=r@^ z3=A;X0|EpB5JLkD_khk1VL1Y6gY@CX0!BM^DGqY*D1}6VM=2NN(4<5N^JsL3XN8Dq zCly6j-Z6@}_Ri8p(<-UGQ`KaPTx$1YT3)qM`=8TH7P4#>v~YJh=uGjckI+aU#ZbT) zHS3JI)xS^kGA(eQvMnw!&qdnES>$X@+4jC{Ys$8L+18XH zVLwS|d6MWLNs3CeIr(9dT(xQ5BVnG^O(L>-m8YBUpk5(YV}2h`zNTujUau!gzN;pS zs>$lK$*QuR7+FqM8|7m)9ka%sNk?`@LyiD zh;@vf!G(69Gwrxg{2yFKyCLf)#VM+dEQwF&J%i92BtSy$2vIzX#_?Dz)AF)9SyW}C zvI|Ac(=HB<%xgt|1d4jCTrwVE!6(8xbx3U^yQ1?cdZ*@f*5KEnKIu z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q8wy=2K76(F#w;dKF>0HmlDRRtS)B2VC2V-T&XYj; uz7M*Eun{%*Os!y&J2^2<#8a73`C^<5b z)+iHEjZ78f=}IPbS{9XZb8?F6e4*oa>wuI~+7;0N1kH%F*aUt6D@8RtDg^$3_zso-X-7)+7iFDRcLa|n zlgX4x%*$(J%VbeE5?LbabRm!`(d=1~^(LY$Ax+kGCgN39qQl*iiJ7*hdbbbBL^^pLTuCK38#ed4&r zf@85rv62=gs^GPt_Md4g(ryiBrNneqe8d~&@+>Jj{uc+vLz!A0Y2}_!~WYfv<)5$Yx=JCnN^YQvd zIt1m>t^yLF<=ejD(%0HYo-T0NwC!e+9xo`r<2mN@wy3UlNnC@?5>X4AK8goiWS`YS3976f9Lxxns1j+i{)zOC0Gz)5^L{R8Q_$yfjY literal 0 HcmV?d00001 diff --git a/cotisations/migrations/__pycache__/0005_auto_20160702_1532.cpython-34.pyc b/cotisations/migrations/__pycache__/0005_auto_20160702_1532.cpython-34.pyc new file mode 100644 index 0000000000000000000000000000000000000000..372205d625b7843049efbe6bbca03335f8a2a91b GIT binary patch literal 707 zcmZ`$%Wl&^6g_?>c2d+8Wfo_U~l+9@BnIsNlJ005ux(#c-f(^ek z3pT8};RD#vI}TMNA;!K}_ce3QocT50i@*L@zyIa{Ke4lXiciRzQ*wfS2MQ=1OdU8j zccEOA9;O~jA5$OBYvDoo_(Dw|(!(;qhWY_Sfb%50rh||;X1}Y7ycUwFqLrGfCUH$% z7IV$pqOKYfmef>DZpUxeh=LQc<_$RsOM*B|U5Gu*iIWHETf8j;!V@9H05ZgK05OD! zAYzCSHgGra>=r7HiPk+6y}iXYqr7g5<}Z(fEXy7--nBKGWJiy)C)tD@9Z#MTSxb;r zyp(1z<9XX@Y5YD7^M$GZer&`Lc>6qFi?>OW|(oK5th#Jjr>5exj-8_ehGg` z4F%OT`~VtQ$=u`y?3KK$-B0?ym48lmquKY>JLLlWfUUoRW`C!*}Qq(a56 zj;gYdv@4rh>7c@-P`N4JJTr98aHy|1aWEv1L*@dz3k7oWfcxgWfdQUpEC3$BatsV@ z0xSd;0owsKg=_H8{)OyrAXq#=_JG~8z!|XH!1fX7Bd~BG!`<$ns(U(oy`ipm@}?`* zUl|Y5G(91-?;0{sk51Fa>6{#$9M4g!(MM`p@oc=HdDly>eG}@@qU3^M&%9UgsrO(zDw?7kGa!4P)t>h4B26 z4zZrT7)aTyj+z!P+TQLrkOx?6r(e&Kk5neB)hdyE-XvSyOK$#$1p9dUe;*$mwx6U? zWkjfboTgsrhfaX+fjfL{{vr;Hu0?P9Oo%l7(IH#Xx@ZpBd#lCrx79c72JfM%o;(@4 O^3-6J(K>VQdw&3qU}fjX4akyaSNpB@`&Rxr-VC08U%dNj1N?xs;i7$lOP%7za9SV$3JVeo zEaTfCY$zN^94K5!T(Dj<2bc?=G3Ww!U_O9rj1Pbf;BDwF@gfKxQ?F-$_005udoUjY z!#M)x0}J39Y_%xp;TwtJ}Rf%f05sOyci zYI1cW<6#`fM})RbMW*roQG6Uv$^MgrL)2>Yk&+f%4`(!OTFJHBxr15G1=B;uXS5Yf z;?|<7F@atY!ON_h%_#KSPqBhnEgL+J4N;+N5mjd7N z%&?cPIq**}Xz%OstG;{})j?I`qjxX;4dgCjyY1JD=#t84u~K(|OE%Xo literal 0 HcmV?d00001 diff --git a/cotisations/models.py b/cotisations/models.py index 170cdd3a..206bdb1a 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -6,17 +6,16 @@ from users.models import User class Facture(models.Model): user = models.ForeignKey('users.User', on_delete=models.PROTECT) - article = models.ForeignKey('Article', on_delete=models.PROTECT) paiement = models.ForeignKey('Paiement', on_delete=models.PROTECT) - banque = models.ForeignKey('Banque', on_delete=models.PROTECT) - cheque = models.CharField(max_length=255) + banque = models.ForeignKey('Banque', on_delete=models.PROTECT, blank=True, null=True) + cheque = models.CharField(max_length=255, blank=True) number = models.IntegerField() date = models.DateTimeField(auto_now_add=True) name = models.CharField(max_length=255) prix = models.DecimalField(max_digits=5, decimal_places=2) def __str__(self): - return str(self.name) + ' ' + str(self.article) + return str(self.name) class Article(models.Model): name = models.CharField(max_length=255) @@ -42,7 +41,6 @@ class NewFactureForm(ModelForm): def __init__(self, *args, **kwargs): super(NewFactureForm, self).__init__(*args, **kwargs) - self.fields['user'].label = 'Adherent' self.fields['number'].label = 'Quantité' self.fields['cheque'].required = False self.fields['banque'].required = False @@ -50,7 +48,7 @@ class NewFactureForm(ModelForm): class Meta: model = Facture - exclude = ['name', 'prix'] + exclude = ['user', 'prix', 'name'] class EditFactureForm(ModelForm): def __init__(self, *args, **kwargs): @@ -65,4 +63,4 @@ class EditFactureForm(ModelForm): class Meta: model = Facture - exclude = ['user'] + fields = '__all__' diff --git a/cotisations/templates/cotisations/facture.html b/cotisations/templates/cotisations/facture.html index 8b2b9b58..dd3b917b 100644 --- a/cotisations/templates/cotisations/facture.html +++ b/cotisations/templates/cotisations/facture.html @@ -4,7 +4,7 @@ {% block title %}Création et modification de factures{% endblock %} {% block content %} -{% bootstrap_form_errors userform %} +{% bootstrap_form_errors factureform %}
{% csrf_token %} diff --git a/cotisations/templates/cotisations/index.html b/cotisations/templates/cotisations/index.html index a65b18ed..ce326948 100644 --- a/cotisations/templates/cotisations/index.html +++ b/cotisations/templates/cotisations/index.html @@ -7,20 +7,22 @@ - - + + + - {% for user in users_list %} + {% for facture in facture_list %} - - - - - + + + + + + {% endfor %}
Designation UtilisateurArticleDesignationNombrePrix unitaire Moyen de paiement Date
{{ facture_list.name }}{{ facture_list.user }}{{ facture_list.article }}{{ facture_list.paiement }}{{ facture_list.date }}{{ facture.user }}{{ facture.name }}{{ facture.number }}{{ facture.prix }}{{ facture.paiement }}{{ facture.date }}
diff --git a/cotisations/views.py b/cotisations/views.py index a5fa5549..535f91cd 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -8,6 +8,7 @@ from django.template import Context, RequestContext, loader from django.contrib import messages from cotisations.models import NewFactureForm, EditFactureForm, Facture, Article +from users.models import User def form(ctx, template, request): c = ctx @@ -15,10 +16,19 @@ def form(ctx, template, request): return render_to_response(template, c, context_instance=RequestContext(request)) def new_facture(request, userid): - facture = Facture.objects.create(user=userid) + try: + user = User.objects.get(pk=userid) + except User.DoesNotExist: + messages.error(request, u"Utilisateur inexistant" ) + return redirect("/cotisations/") + facture = Facture(user=user) facture_form = NewFactureForm(request.POST or None, instance=facture) if facture_form.is_valid(): - facture_form.save() + new_facture = facture_form.save(commit=False) + article = facture_form.cleaned_data['article'] + new_facture.prix = article[0].prix + new_facture.name = article[0].name + new_facture.save() messages.success(request, "La facture a été crée") return redirect("/cotisations/") return form({'factureform': facture_form}, 'cotisations/facture.html', request) @@ -34,7 +44,7 @@ def edit_facture(request, factureid): facture_form.save() messages.success(request, "La facture a bien été modifiée") return redirect("/cotisations/") - return form({'factureform': facture}, 'cotisations/facture.html', request) + return form({'factureform': facture_form}, 'cotisations/facture.html', request) def index(request): facture_list = Facture.objects.order_by('pk')