From 99b5bd1ca9d5c3e0d4a567555acc0426573198dc Mon Sep 17 00:00:00 2001 From: kououken Date: Mon, 4 Feb 2019 18:29:05 -0800 Subject: [PATCH 01/11] Configure registration app --- back/Pipfile | 3 ++- back/reimbursinator/settings.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/back/Pipfile b/back/Pipfile index 54943ec..c996bfc 100644 --- a/back/Pipfile +++ b/back/Pipfile @@ -9,8 +9,9 @@ verify_ssl = true django = "==2.1.5" django-cors-headers = "==2.4.0" djangorestframework = "==3.8.2" -gunicorn = "==19.6.0" django-rest-auth = "==0.9.3" +django-allauth = "==0.37.1" +gunicorn = "==19.6.0" [requires] python_version = "3.5" diff --git a/back/reimbursinator/settings.py b/back/reimbursinator/settings.py index 6fb5556..503958c 100644 --- a/back/reimbursinator/settings.py +++ b/back/reimbursinator/settings.py @@ -39,10 +39,14 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django.contrib.sites', # 3rd party 'rest_framework', 'rest_framework.authtoken', + 'allauth', + 'allauth.account', 'rest_auth', + 'rest_auth.registration', 'corsheaders', # local 'users', @@ -149,3 +153,9 @@ USE_TZ = True # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/' + +# Email Config + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +SITE_ID = 1 From 72ab00dd503277ed4d93ada26ca3a17ff88e988c Mon Sep 17 00:00:00 2001 From: kououken Date: Tue, 5 Feb 2019 14:56:48 -0800 Subject: [PATCH 02/11] User registration endpoint working. --- back/Pipfile.lock | 72 +++++++++++++++++++++++++++++++++++- back/db.sqlite3 | Bin 59392 -> 71680 bytes back/reimbursinator/urls.py | 1 + 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/back/Pipfile.lock b/back/Pipfile.lock index e493330..a6ed173 100644 --- a/back/Pipfile.lock +++ b/back/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "d3bf402a934e168cbdc04022effcdb9ff8d4fde5b83d79bb388ad2a4c547894a" + "sha256": "b1fc6b06ec8daa4efd9573865bc6c1732ae9354309e036bfe3ce0ab76b1a3bcd" }, "pipfile-spec": 6, "requires": { @@ -16,6 +16,27 @@ ] }, "default": { + "certifi": { + "hashes": [ + "sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7", + "sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033" + ], + "version": "==2018.11.29" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, + "defusedxml": { + "hashes": [ + "sha256:24d7f2f94f7f3cb6061acb215685e5125fbcdc40a857eff9de22518820b0a4f4", + "sha256:702a91ade2968a82beb0db1e0766a6a273f33d4616a6ce8cde475d8e09853b20" + ], + "version": "==0.5.0" + }, "django": { "hashes": [ "sha256:a32c22af23634e1d11425574dce756098e015a165be02e4690179889b207c7a8", @@ -24,6 +45,13 @@ "index": "pypi", "version": "==2.1.5" }, + "django-allauth": { + "hashes": [ + "sha256:02175aa1c2ddfd935a54011d1196d70c976647fc46f603f8b8758fc395b9d277" + ], + "index": "pypi", + "version": "==0.37.1" + }, "django-cors-headers": { "hashes": [ "sha256:5545009c9b233ea7e70da7dbab7cb1c12afa01279895086f98ec243d7eab46fa", @@ -55,6 +83,27 @@ "index": "pypi", "version": "==19.6.0" }, + "idna": { + "hashes": [ + "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", + "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" + ], + "version": "==2.8" + }, + "oauthlib": { + "hashes": [ + "sha256:0ce32c5d989a1827e3f1148f98b9085ed2370fc939bf524c9c851d8714797298", + "sha256:3e1e14f6cde7e5475128d30e97edc3bfb4dc857cb884d8714ec161fdbb3b358e" + ], + "version": "==3.0.1" + }, + "python3-openid": { + "hashes": [ + "sha256:0086da6b6ef3161cfe50fb1ee5cceaf2cda1700019fda03c2c5c440ca6abe4fa", + "sha256:628d365d687e12da12d02c6691170f4451db28d6d68d050007e4a40065868502" + ], + "version": "==3.1.0" + }, "pytz": { "hashes": [ "sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9", @@ -62,12 +111,33 @@ ], "version": "==2018.9" }, + "requests": { + "hashes": [ + "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", + "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" + ], + "version": "==2.21.0" + }, + "requests-oauthlib": { + "hashes": [ + "sha256:bd6533330e8748e94bf0b214775fed487d309b8b8fe823dc45641ebcd9a32f57", + "sha256:d3ed0c8f2e3bbc6b344fa63d6f933745ab394469da38db16bdddb461c7e25140" + ], + "version": "==1.2.0" + }, "six": { "hashes": [ "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" ], "version": "==1.12.0" + }, + "urllib3": { + "hashes": [ + "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", + "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" + ], + "version": "==1.24.1" } }, "develop": {} diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 2a1a5530382cc2affd37e357a256cd3fa46289dd..43dd0a70ac73808220ed2638b5dc6c8b5c5a8e6c 100644 GIT binary patch delta 4832 zcmcgweN0=|6~FhM$5*fk1c*r>#eq<8`0#tretvccOGpBQg6%*c6uQha_5&OIRojF> zr#VFFAN^-r^8V1Qpm4^-yx)!D$|&%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Z<<}>J*^zwLXfeYh^A#7PL?V7d$B3Wppl$cZ-0p3>Sow$ld1)6PT{zvsbkfq$ z+DhLGO(YNJ(+}11LBf5NUBWUw6NzkUIH>U0S5I(9rLHMa%%>8vd1Dhrag&Mrvx$n% zqA&f&+<%Yh--sC$%<2Y3p>Ma}JAWh2Mwr6SRJL0Zrf{>z%Mbqb)JL;6x|MHVc#(B@ z_+sT5V}0Qj*nK^Lt{z!=&fnc72Yg2Qo3j!ebeUIw*Ca~%DK(ZaziB`4f8|ueF(p3S zU(jYWB|5a*7Yz^QH94BshF{KVGdV>a>dVK&`q5}1rf3CqI$k(19p%5=Ca?28 z9aSTPV`^64sm%BKL$QFmpYQvk)!FTlA8~); z#xdqF+v&k0ibu?jT?1cVua@Qs=0$c9e11jUL~)(qy2zIxwd2(qzPRE&wJOz`9Vy;! PvA0XC{*EdMw1)i)68}4Y diff --git a/back/reimbursinator/urls.py b/back/reimbursinator/urls.py index 62397e8..b39c33f 100644 --- a/back/reimbursinator/urls.py +++ b/back/reimbursinator/urls.py @@ -13,5 +13,6 @@ urlpatterns = [ path('admin/', admin.site.urls), path('api/v1/', include("backend.urls")), path('api/v1/account/', include('rest_auth.urls')), + path('api/v1/account/register/', include('rest_auth.registration.urls')), path('api-auth/', include('rest_framework.urls')), ] From 6e8478cf67766efea942ca7849aaff3c6f9c94e5 Mon Sep 17 00:00:00 2001 From: kououken Date: Tue, 5 Feb 2019 15:38:34 -0800 Subject: [PATCH 03/11] Changed to email instead of username, added first and last name. --- back/db.sqlite3 | Bin 71680 -> 89088 bytes back/reimbursinator/settings.py | 12 ++++++++ back/reimbursinator/urls.py | 1 + back/users/serializers.py | 47 ++++++++++++++++++++++++++++++++ back/users/views.py | 2 -- 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 back/users/serializers.py diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 43dd0a70ac73808220ed2638b5dc6c8b5c5a8e6c..85281da711c907b2d1d5a7697864a5705948c739 100644 GIT bin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YP_dg>rW>_e&JDa z@aMMHBZS*b_4Rn7hF+g7T{Q>(tG7%S+_B`%`B34GWSLW!#k@N(6pRFhDrBkB?D4jn zJsr)><_?d$rNc#ocMhtzPnHnSK%=TXwFBnQ$8HsD4x40C!)M>rFDt|q2+qMv;DHkI zEqR-yh!LN{`*8)USOHcmrmkuz_xaWyZJsibx9Ptsq$C?+KCw08>1v4kMqMLHY(Vn0 zw@99?F2URAvin9m6N=an=}vaXlvpC_-P#)W(d(BM(On;CF;CB2%(U4&Te}lJQQ7Nl zZ;dFU9d^%Xcg!;yw|PYOsFLj1qjYsL@)n`H%PlCQab9U}vAI+HUlJ8+?@M$(*NIDG zM33P jxJoP!WM`rzdcSh0Z2~oQ&#w$jbwaIrY~YI=wNC0G&bT3@HOESkW+DIBTKGY|Ya8Ev>Fi z?Jl#Mm4Bz%!qnB+sxkFQ59oBIN+)+=`ov^g8RI_N$aLHzVH8cF7O!@EtygR6s>kC^ zbmQzs&7Az|>C>~y!a37ouCU~8On)?FsZ_1^F6%THZX&qJBK!`_C0K)W`FIVNYvU(! zlQo!5=I%law-DT#%R?~2n*6^x7_b55Au}Q$ks*A68JF4fz@RmEk87k(jmcfk@-QE| zRfvmQ+5RWv>)W-a>T0~dG8^bigde!{=c0Xhy?(wp?VC0?yUdn{w{vYqKfb$y?yf5~ zO8ou)svI}B(Ur4HScPBEJffao&ARY$J?1zl!$%KkjkuO|QW~E)T8ukL0YDtV6ub^` NmVPfBiktAOzXP4Y3AX?M diff --git a/back/reimbursinator/settings.py b/back/reimbursinator/settings.py index 503958c..8725757 100644 --- a/back/reimbursinator/settings.py +++ b/back/reimbursinator/settings.py @@ -45,6 +45,7 @@ INSTALLED_APPS = [ 'rest_framework.authtoken', 'allauth', 'allauth.account', + 'allauth.socialaccount', 'rest_auth', 'rest_auth.registration', 'corsheaders', @@ -159,3 +160,14 @@ STATIC_URL = '/static/' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' SITE_ID = 1 + +# Registration + +ACCOUNT_USER_MODEL_USERNAME_FIELD = 'username' +ACCOUNT_EMAIL_REQUIRED = True +ACCOUNT_USERNAME_REQUIRED = False +ACCOUNT_AUTHENTICATION_METHOD = 'email' + +REST_AUTH_REGISTER_SERIALIZERS = { + 'REGISTER_SERIALIZER': 'users.serializers.RegisterSerializer', +} diff --git a/back/reimbursinator/urls.py b/back/reimbursinator/urls.py index b39c33f..7a33b6d 100644 --- a/back/reimbursinator/urls.py +++ b/back/reimbursinator/urls.py @@ -14,5 +14,6 @@ urlpatterns = [ path('api/v1/', include("backend.urls")), path('api/v1/account/', include('rest_auth.urls')), path('api/v1/account/register/', include('rest_auth.registration.urls')), + # path('api/v1/account/register/', NameRegistrationView.as_view()), path('api-auth/', include('rest_framework.urls')), ] diff --git a/back/users/serializers.py b/back/users/serializers.py new file mode 100644 index 0000000..91416a4 --- /dev/null +++ b/back/users/serializers.py @@ -0,0 +1,47 @@ +from rest_framework import serializers +from allauth.account import app_settings as allauth_settings +from allauth.utils import email_address_exists +from allauth.account.adapter import get_adapter +from allauth.account.utils import setup_user_email +from django.utils.translation import gettext as _ + +class RegisterSerializer(serializers.Serializer): + email = serializers.EmailField(required=allauth_settings.EMAIL_REQUIRED) + first_name = serializers.CharField(required=True, write_only=True) + last_name = serializers.CharField(required=True, write_only=True) + password1 = serializers.CharField(required=True, write_only=True) + password2 = serializers.CharField(required=True, write_only=True) + + def validate_email(self, email): + email = get_adapter().clean_email(email) + if allauth_settings.UNIQUE_EMAIL: + if email and email_address_exists(email): + raise serializers.ValidationError( + _("A user is already registered with this e-mail address.")) + return email + + def validate_password1(self, password): + return get_adapter().clean_password(password) + + def validate(self, data): + if data['password1'] != data['password2']: + raise serializers.ValidationError( + _("The two password fields didn't match.")) + return data + + def get_cleaned_data(self): + return { + 'first_name': self.validated_data.get('first_name', ''), + 'last_name': self.validated_data.get('last_name', ''), + 'password1': self.validated_data.get('password1', ''), + 'email': self.validated_data.get('email', ''), + } + + def save(self, request): + adapter = get_adapter() + user = adapter.new_user(request) + self.cleaned_data = self.get_cleaned_data() + adapter.save_user(request, user, self) + setup_user_email(request, user, []) + user.save() + return user diff --git a/back/users/views.py b/back/users/views.py index 91ea44a..2536b37 100644 --- a/back/users/views.py +++ b/back/users/views.py @@ -1,3 +1 @@ from django.shortcuts import render - -# Create your views here. From bdddb3cc033d613b2cd0aafb71b8223bdfc56b64 Mon Sep 17 00:00:00 2001 From: kououken Date: Tue, 5 Feb 2019 15:49:03 -0800 Subject: [PATCH 04/11] Changed username frank to frank@frank.com. Password is still frank12345 --- back/db.sqlite3 | Bin 89088 -> 89088 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 85281da711c907b2d1d5a7697864a5705948c739..1b759a475639ad1b2f16c066053118c728aac9a2 100644 GIT binary patch delta 601 zcmZqJ!P>Bcb%HeSMFs|ja42S+sA0}{abp4tH>3RKRPH${+)O(em>Js`m?Ih6HuD%% zF$y%AF!3=oYC3Xgi_2JEx8S8?!P4^Bran=IzYN%#)aNftvZ5RaBUL z8OzK}jV;TJ3-Sx|&8o6;GBS*pp{1^Yk*lbMMGOh}t(nTZXFbzC)1(`51>u}vC5 zQw_Ma4lV@2U*IC#MOv^3BE_}f&ZXNfTq&drC${bc7vJH2=icve4!5&s>FilvOgaw< zf>=8Z)9y8aJnXHT?c@y3+245V#s!!H1gNHc>|oj?o!-ziI#VqphLsi=w7~GQi1Q=K z&mtP}ynsZb+Zw}!f^LammXdjOx$=3$g$#|#J zX|)9jT}GODXWHb_572{A#_tvVh^JW*`B))e*Ds(ey2_Ou9PeiZn)UJ$$Kx;D;`kr! z@ST94aD*MvPjIPVHME@@IzSl*+i;aLR&bM>ja(gUFhSxUE9d8724tOT1@PFE4Y2&E zZ#I~cPIZRNRnSY%UXPG4Fgg%k7+}}uBfx{_w)s&DL<#r?QRu@?#%wT~$rryWluM{80BN695yd57gkzK;{ z(ST*0HH+&{Z%`JwYYG0ZuYy)NwY`ee;u0^f#fu8MT~Z=<%dyD)QY@U@mJ@1IEhZT` zyyR69@eLWt23Hewr8hyg^y6Mbe}_Y3((sF%`g^ie_iN`dHcuVH?j4FG`__BpFZd0A Ck-3rp From d683ea8839495650e6a4631489884629aec4f398 Mon Sep 17 00:00:00 2001 From: kououken Date: Wed, 6 Feb 2019 13:22:40 -0800 Subject: [PATCH 05/11] Fixed user authentication backend to allow login with email. --- back/db.sqlite3 | Bin 89088 -> 89088 bytes back/reimbursinator/settings.py | 9 +++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 1b759a475639ad1b2f16c066053118c728aac9a2..8074d09696b7ab103c40188a656433376bef08ba 100644 GIT binary patch delta 1175 zcma)5U2NM_6t;bmI!=GmrVSgTgETEa8*RAP|87+=Z%wWB)GEN$x432WE2 z%{0-Bkv<`T{Ln|9c%8HwkqLDm?Wx++KunVWF$p0M5~_GWn%Kj{bp_H;CxLYQ`Cj|; zIp25g@%jz_`VIew&(M!P>ODa}y8iYTL7H`*YfT)8^>8pmFE14rm) ztf;D>5*29@rDF7W)y|XMF>=KVReRqjNM_>-(o{)y8o24BDCz@8=QqOjj(Qt-La9I` za`?pnCpdlhDJRd54xSc`9AQC{RrhNF z^>qA90o-BW0o;LI*mXNkegoa4K1BtH*kAx6dtC+h!BqPo#6WV`)mK|UhY^t6uHIjn zupelei|t|G9!A}XOE-Oln{n86!p*^(kRjYw2>F1cV;=N*5OrtY`vm#>;UqNO&QA|O zv>=vpYgJ3OD`mbatSA_-u9WR%RV-WObE^H0JJDzr!Y<%9dPg&Wq<7LAdFD0#{W%6gs$qBN`7$|ES zYpL`kGSdb!YG-gV?L_bON(p4xr}^we0%t7~8}=m1j_I`|Z?2lPIVo#Ru9#`^#>!fT zWs0U{3gqsbzjug!!|A-6f0C7}ci(5&hu&dOGU?h6;Ou_a*5Y+G$Zmaq0ZwSRD9Bn- zIfn{zF)s_6$ZI*NAc{pv%;&skSQb>2d%~2(HAzx6A?P;m{{ch)HxctP%y7=l`!8+% z^e50k_u((0gZ|%O8@7qQYp}TubbO$vCCs)^0gmnuJ~rt=Z<5G7!|$*IJB0o@Z0@l1 z3*jyZK|lQ%ll?3}`(A7FF}EmaK$h8MZV~zxlQ|mWD7~w@o#yC$jwCHEs#wxwj7TaD ztiB+nha&aX{bV$Z<+#FYq9O|3ui|{XacJ|$41I89Fd8e`x%q|I%;n279CI{E>V+cv a>tStJ;NudOu_9>s`Go}znvD!y^Zf;2dqN8U delta 786 zcma)4OHUI~6u!5o(+=-~yo@AmA_@jt=Ka7BTOPJb2@5f%3nN3Bu@!3RgG!4FR4iM~ zEcgZPjERh~Xh65b6&Q7+kqwE7iL6YBuDsKo#zgbwo}7I5%gJ{hE1T5HCiUP1-h0?J zg7=8%^<@V3@~A1~(gZ0=foF_%xL?3}ii>(;s(Um(C`1TkE8454Y$!@L>Q zvRdL&HKdaHM9$8F)fkAUQyjypeunciqL1STd0~)K0+OtVs)P{kM|aL3x~JeS@u|F$nH*S(go;A(;(%Hj4XLUaRpbld@#sh1nATz8aSZ{fzwecGQ*hO#zyKn#pmM8KKj?vIo9S73Qvg~19hZ#xNNnC=yu@quOBd&E!?sK80f^Q;4W1xe)90>6;Xq@~i0`9zW{ zhzUVvZxxGrHkDko!j*cug;njz3CbWZ2SkSDS>DoL@3opir>FPsSvNJYN`?Me>FWnK zZu+y#>ihc+_aP7u34?12kl@VS}mcG6Cv2KLF6xCeaDSYw-CDJHzho$u`}wzK<>Cqgtwtm IzJg26Un7R*n*aa+ diff --git a/back/reimbursinator/settings.py b/back/reimbursinator/settings.py index 8725757..86f1b58 100644 --- a/back/reimbursinator/settings.py +++ b/back/reimbursinator/settings.py @@ -163,11 +163,16 @@ SITE_ID = 1 # Registration -ACCOUNT_USER_MODEL_USERNAME_FIELD = 'username' +#ACCOUNT_USER_MODEL_USERNAME_FIELD = 'email' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_AUTHENTICATION_METHOD = 'email' REST_AUTH_REGISTER_SERIALIZERS = { - 'REGISTER_SERIALIZER': 'users.serializers.RegisterSerializer', + 'REGISTER_SERIALIZER': 'users.serializers.RegisterSerializer', } + +AUTHENTICATION_BACKENDS = ( + 'django.contrib.auth.backends.ModelBackend', + 'allauth.account.auth_backends.AuthenticationBackend', +) From 10c2a3e1500366462db159f0817732d6de1159ae Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Wed, 6 Feb 2019 15:31:15 -0800 Subject: [PATCH 06/11] Add frontend registration functionality --- front/static/edit_report.html | 2 +- front/static/home.html | 2 +- front/static/index.html | 2 +- front/static/js/login.js | 2 +- front/static/js/signupPage.js | 74 ++++++++++++++++++++++++++++------- front/static/login.html | 6 +-- front/static/new_report.html | 2 +- front/static/signup.html | 23 ++++++----- 8 files changed, 80 insertions(+), 33 deletions(-) diff --git a/front/static/edit_report.html b/front/static/edit_report.html index 80d39df..474746f 100644 --- a/front/static/edit_report.html +++ b/front/static/edit_report.html @@ -36,7 +36,7 @@ -
+
diff --git a/front/static/home.html b/front/static/home.html index 114887d..d272129 100644 --- a/front/static/home.html +++ b/front/static/home.html @@ -35,7 +35,7 @@
-
+

Welcome to Reimbursinator

diff --git a/front/static/index.html b/front/static/index.html index 713bb3a..f759c1b 100644 --- a/front/static/index.html +++ b/front/static/index.html @@ -27,7 +27,7 @@
-
+

Reimbursinator

An open source expense management solution sponsored by the Software Freedom Conservancy

diff --git a/front/static/js/login.js b/front/static/js/login.js index 20b411d..0bdaa9b 100644 --- a/front/static/js/login.js +++ b/front/static/js/login.js @@ -2,7 +2,7 @@ function postToLoginEndpoint(event) { event.preventDefault(); const credentials = { - "username" : this.elements.username.value, + "email" : this.elements.email.value, "password" : this.elements.password.value } const url = "https://" + window.location.hostname + ":8444/api/v1/account/login/"; diff --git a/front/static/js/signupPage.js b/front/static/js/signupPage.js index 0055cce..8d348ad 100644 --- a/front/static/js/signupPage.js +++ b/front/static/js/signupPage.js @@ -1,20 +1,64 @@ -const password = document.getElementById("password"); -const confirm_password = document.getElementById("confirmPassword"); -function validatePassword(){ - if(password.value != confirm_password.value) { - confirm_password.setCustomValidity("Passwords Don't Match"); - } - else { - confirm_password.setCustomValidity(''); +const password1 = document.getElementById("password1"); +const password2 = document.getElementById("password2"); + +function validatePassword() { + if (password1.value != password2.value) { + password2.setCustomValidity("Passwords don't match"); + } else { + password2.setCustomValidity(''); } } -password.onchange = validatePassword; -confirm_password.onkeyup = validatePassword; +password1.onchange = validatePassword; +password2.onkeyup = validatePassword; -function validateEmail(email) -{ - if(email.validity.patternMismatch) +function validateEmail(email) { + if (email.validity.patternMismatch) { email.setCustomValidity('Please input correct email'); - else + } else { email.setCustomValidity(''); -} \ No newline at end of file + } +} + +function postToRegistrationEndpoint(event) { + event.preventDefault(); + + const credentials = { + "email" : this.elements.email.value, + "first_name" : this.elements.first_name.value, + "last_name" : this.elements.last_name.value, + "password1" : this.elements.password1.value, + "password2" : this.elements.password2.value + } + const url = "https://" + window.location.hostname + ":8444/api/v1/account/register/"; + const xhr = new XMLHttpRequest(); + + console.log("Attempting a connection to the following endpoint: " + url); + console.log("User credentials:\n" + JSON.stringify(credentials)); + + xhr.open("POST", url, true); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.onreadystatechange = function() { + if (this.readyState === 4) { + if (this.status === 201) { + console.log("REGISTRATION SUCCESS!"); + console.log("Server response:\n" + this.response); + token = JSON.parse(this.response).key; + localStorage.setItem("token", token); + window.location.replace("home.html"); + } else { + console.error("LOGIN FAILURE!"); + console.error("Server status: " + this.status); + console.error("Server response:\n" + this.response); + } + } + }; + + xhr.onerror = function() { + alert("Error connecting to the authentication server!"); + }; + + xhr.send(JSON.stringify(credentials)); +} + +const form = document.querySelector("form"); +form.addEventListener("submit", postToRegistrationEndpoint); diff --git a/front/static/login.html b/front/static/login.html index 9a8af2f..f8b5a07 100644 --- a/front/static/login.html +++ b/front/static/login.html @@ -14,7 +14,7 @@ -
+
@@ -24,8 +24,8 @@
- - + +
diff --git a/front/static/new_report.html b/front/static/new_report.html index 6f0506b..f1cc53b 100644 --- a/front/static/new_report.html +++ b/front/static/new_report.html @@ -35,7 +35,7 @@
-
+

Create a new report

diff --git a/front/static/signup.html b/front/static/signup.html index ebfeb1b..12b1119 100644 --- a/front/static/signup.html +++ b/front/static/signup.html @@ -14,7 +14,7 @@ -
+
@@ -23,21 +23,25 @@
-
- - -
- - + +
- - + + +
+
+ + +
+
+ +
@@ -51,5 +55,4 @@
- From fc2d2e9e9dc4867eb58d587af2ea689ca7d588c4 Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Wed, 6 Feb 2019 15:44:15 -0800 Subject: [PATCH 07/11] Fix formatting mistakes --- front/static/home.html | 2 +- front/static/js/signupPage.js | 2 +- front/static/login.html | 8 ++++---- front/static/new_report.html | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/front/static/home.html b/front/static/home.html index d272129..99d984c 100644 --- a/front/static/home.html +++ b/front/static/home.html @@ -35,7 +35,7 @@
-
+

Welcome to Reimbursinator

diff --git a/front/static/js/signupPage.js b/front/static/js/signupPage.js index 8d348ad..8777450 100644 --- a/front/static/js/signupPage.js +++ b/front/static/js/signupPage.js @@ -46,7 +46,7 @@ function postToRegistrationEndpoint(event) { localStorage.setItem("token", token); window.location.replace("home.html"); } else { - console.error("LOGIN FAILURE!"); + console.error("REGISTRATION FAILURE!"); console.error("Server status: " + this.status); console.error("Server response:\n" + this.response); } diff --git a/front/static/login.html b/front/static/login.html index f8b5a07..a09051e 100644 --- a/front/static/login.html +++ b/front/static/login.html @@ -24,12 +24,12 @@
- - + +
- - + +

diff --git a/front/static/new_report.html b/front/static/new_report.html index f1cc53b..5d8dd49 100644 --- a/front/static/new_report.html +++ b/front/static/new_report.html @@ -35,7 +35,7 @@
-
+

Create a new report

From 38a9464870c0bf6aa412496007d82d990a59af1c Mon Sep 17 00:00:00 2001 From: kououken Date: Thu, 7 Feb 2019 15:32:21 -0800 Subject: [PATCH 08/11] Implemented policy parsing, applied policy to report creation, added field_name to fields. --- .../migrations/0005_field_field_name.py | 18 ++++ back/backend/models.py | 3 +- back/backend/policy.py | 68 +++++++------ back/backend/test.py | 3 + back/backend/views.py | 93 +++++------------- back/db.sqlite3 | Bin 89088 -> 97280 bytes 6 files changed, 87 insertions(+), 98 deletions(-) create mode 100644 back/backend/migrations/0005_field_field_name.py create mode 100644 back/backend/test.py diff --git a/back/backend/migrations/0005_field_field_name.py b/back/backend/migrations/0005_field_field_name.py new file mode 100644 index 0000000..caf25f5 --- /dev/null +++ b/back/backend/migrations/0005_field_field_name.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.5 on 2019-02-07 22:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('backend', '0004_auto_20190131_1645'), + ] + + operations = [ + migrations.AddField( + model_name='field', + name='field_name', + field=models.CharField(default='field', max_length=512), + ), + ] diff --git a/back/backend/models.py b/back/backend/models.py index bb26ed3..b59c1ec 100644 --- a/back/backend/models.py +++ b/back/backend/models.py @@ -26,12 +26,13 @@ class Section(models.Model): class Field(models.Model): section_id = models.ForeignKey(Section, on_delete=models.CASCADE) + field_name = models.CharField(max_length=512, default="field") label = models.CharField(max_length=512) number = models.IntegerField() type = models.CharField(max_length=128) completed = models.BooleanField(default=False) data_bool = models.BooleanField(default=False) - data_decimal = models.DecimalField(max_digits=9,decimal_places=2, null=True, blank=True) + data_decimal = models.DecimalField(max_digits=9, decimal_places=2, null=True, blank=True) data_date = models.DateField(default=datetime.date.today) data_file = models.FileField(upload_to='uploads/%Y/%m/%d/', max_length=512, null=True, blank=True) data_string = models.TextField(default='', blank=True) diff --git a/back/backend/policy.py b/back/backend/policy.py index 95e401b..1131e30 100644 --- a/back/backend/policy.py +++ b/back/backend/policy.py @@ -1,10 +1,36 @@ -# simple_policy.py from datetime import date -from policy import Policy, Section -# - For the rules, should one refer to fields by 'section.fields.x' -# or by the section name eg. 'general_section.fields.x'? +#### Classes for policy, sections. +class Policy(): + + def __init__(self): + self.sections = [] + + def add_section(self, section): + self.sections.append(section) + +class Section(): + + def __init__(self, title="Section", html_description="", required=False, auto_submit=False, fields={}): + self.title = title + self.html_description = html_description + self.required = required + self.auto_submit = auto_submit + self.fields = fields + self.rules = [] + + def add_rule(self, title="Rule", rule=None, rule_break_text=""): + rule = { + "title": title, + "rule": rule, + "rule_break_text": rule_break_text, + } + self.rules.append(rule) + +#### Policy configuration begin here + +pol = Policy() #### General #### Section 0 @@ -12,7 +38,7 @@ general_section = Section( title="General Info", html_description="", fields={ - "destination": {"label": "Destination City", "type": "string"} + "destination": {"label": "Destination City", "type": "string"}, } ) @@ -22,7 +48,7 @@ general_section.add_rule( rule_break_text="What did the cowboy say about Tim, his wild horse?" ) -Policy.add_section(general_section) +pol.add_section(general_section) #### Flight #### Section 1 @@ -43,7 +69,7 @@ flight_section.add_rule( rule_break_text="Fares cannot be more than $500" ) -Policy.add_section(flight_section) +pol.add_section(flight_section) #### Lodging #### Section 2 @@ -64,13 +90,13 @@ def nightly_rate_check(report, section): duration = checkout_date - checkin_date return section.fields.cost <= duration * section.fields.rate -section.add_rule( +lodging_section.add_rule( title="", rule=nightly_rate_check, rule_break_text="The average nightly rate cannot be more than the USGSA rate." ) -Policy.add_section(lodging_section) +pol.add_section(lodging_section) #### Local Transportation #### Section 3 @@ -89,7 +115,7 @@ transport_section.add_rule( rule_break_text="Local transportation costs must be less than $10 per day, on average." ) -Policy.add_section(transport_section) +pol.add_section(transport_section) #### Per Diem #### Section 4 @@ -109,24 +135,4 @@ per_diem_section.add_rule( rule_break_text="The average cost per day for per diem expenses cannot be more than the rate specified by the USGSA." ) -Policy.add_section(per_diem_section) - -''' -Section( - title="", - html_description="

", - fields={ - "": {"label": "", "type": ""} - } -) - -section.add_rule( - title="", - rule=lambda report, section: boolean_statement, - rule_break_text="" -) - -#// or, for a rule which doesn’t apply to a specific section... -#// -#// add_general_rule(...) -''' +pol.add_section(per_diem_section) diff --git a/back/backend/test.py b/back/backend/test.py new file mode 100644 index 0000000..6ecdccb --- /dev/null +++ b/back/backend/test.py @@ -0,0 +1,3 @@ +from policy import pol + +print(pol) diff --git a/back/backend/views.py b/back/backend/views.py index 70e3f79..1c368c2 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -1,7 +1,8 @@ from rest_framework.decorators import api_view from django.http import JsonResponse from .models import * - +from .policy import pol +import json # function that prints all the reports def get_reports(report_pk): @@ -47,15 +48,14 @@ def get_sections(r_id): def get_fields(s_id): # create dict of arrays for fields field_set = {"fields": []} - queryset = Field.objects.filter(section_id=s_id) - # queryset = Field.objects.all() + queryset = Field.objects.filter(section_id=s_id).order_by('number') for i in queryset: data = { - "field_name": "TODO", + "field_name": i.field_name, "label": i.label, "type": i.type, "number": i.number, - "value": "get_value", + "value": "i.to_json()", } # append the fields to array # use copy() to avoid overwriting @@ -70,73 +70,34 @@ def report(request): ''' Generate a new empty report and return it ''' - data = { - "title": "2018 Portland trip", - "date_created": "2018-05-22T14:56:28.000Z", - "submitted": False, - "date_submitted": "0000-00-00T00:00:00.000Z", - "sections": [ - { - "id": 1, - "completed": True, - "title": "Flight Info", - "html_description": "

Enter flight details here.

", - "fields": { - "international": { - "label": "International flight", - "type": "boolean", - "value": True - }, - "travel_date": { - "label": "Travel start date", - "type": "date", - "value": "2016-05-22T14:56:28.000Z" - }, - "fare": { - "label": "Fare", - "type": "decimal", - "value": "1024.99" - }, - "lowest_fare_screenshot": { - "label": "Lowest fare screenshot", - "type": "file", - "value": "e92h842jiu49f8..." - }, - "plane_ticket_invoice": { - "label": "Plane ticket invoice PDF", - "type": "file", - "value": "" - } - }, - "rule_violations": [ - { - "error_text": "Plane ticket invoice must be submitted." - } - ] - }, - { - "id": 2, - "completed": False, - "title": "Hotel info", - "html_description": "

If you used a hotel, please enter the details.

", - "fields": { - "total": { - "label": "Total cost", - "type": "decimal" - } - }, - "rule_violations": [ - ] - } - ] - } + + # Create the report + report = Report.objects.create(user_id=request.user, title=request.data['title'], date_created=datetime.date.today()) + report.save() + + # Create the sections + for i in range(len(pol.sections)): + section = pol.sections[i] + s = Section.objects.create(report_id=report, auto_submit=section.auto_submit, required=section.required, completed=False, title=section.title, html_description=section.html_description, number=i) + s.save() + + # Create the fields + j = 0 + for key in section.fields: + field = section.fields[key] + f = Field.objects.create(section_id=s, field_name=key, label=field['label'], number=j, type=field['type'], completed=False) + f.save() + j = j+1 + + # Return the newly created report + data = get_reports(report.id) return JsonResponse(data) # List of reports @api_view(['GET']) def reports(request): report_set = {"reports": []} - queryset = Report.objects.all() + queryset = Report.objects.all().order_by('date_created') for i in queryset: data = { "report_pk": i.id, diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 8074d09696b7ab103c40188a656433376bef08ba..77fd67fd08e54caf24731ac1e3dfd3ef6ad93a2e 100644 GIT binary patch delta 12088 zcmc&)32+qwmpo=-c$?^bPt``Z|4$ev5vOzC@p;PtzCab$UI|JG2k^`Sbe{t-4FTjI1!ydf@7kP1(FD+=jh_-ATf3i>7@(p1zR3hK3` z)Ua_eEG>q@(TdpVqDm~rq#~oXhUzzdo%TxsUw`aRiVoFOl~F$P`ou&i;46;5QBl;9&(1DQHlzLqWZQ?FzOj zs8g_&VL^+6&H3>Yzw>+^70J6X)%|_#beMYRAnm2y)Jd%{jYG7Ja=&ytC6Rbea`in+2C>HQF2wvzd>F9{hcJH_AhZy!+7{Ai6(D=v?2A5GMLQ zVEcW&8}Oa>UcmouKLPk=TMyvBwcQE$ zpy>$UbmL*bOAUtr#~TcQBMlvZLkIPMg9qCIPt>;o9Y&GjvShw7REb#)wI zV_g$qO28957N30hajav~r@v5+$7t^3J&@um zRXm53!E?q)Dd1V60rZd(zyVSW*h83)cacIskrV)$h#Js9RDi97#l;4~462$icYt7k zP%+U09w6oHIgAq(us0ZC!OF{`*wMxA!O$|durxKx`TRa^HMGP<79q@Wq2QW9uMjs}wPXAVDa^V3 z(gG0l1*7oAADj+x-pSBXlv|Lzfe7aXB7bno?~{U2_I*|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gY Date: Thu, 7 Feb 2019 17:13:43 -0800 Subject: [PATCH 09/11] added filter by user_id -- now reports only display based on user id --- back/backend/policy.py | 6 ++++-- back/backend/views.py | 5 +++-- back/db.sqlite3 | Bin 97280 -> 97280 bytes 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/back/backend/policy.py b/back/backend/policy.py index 1131e30..d40f56e 100644 --- a/back/backend/policy.py +++ b/back/backend/policy.py @@ -12,7 +12,8 @@ class Policy(): class Section(): - def __init__(self, title="Section", html_description="", required=False, auto_submit=False, fields={}): + def __init__(self, title="Section", html_description="", required=False, + auto_submit=False, fields={}): self.title = title self.html_description = html_description self.required = required @@ -75,7 +76,8 @@ pol.add_section(flight_section) #### Section 2 lodging_section = Section( title="Hotel Info", - html_description="

Enter hotel info here.\nPer diem rates can be found at

", + html_description="

Enter hotel info here.\nPer diem rates can be found at " + "

", fields={ "check-in_date": {"label": "Check-in date", "type": "date"}, "check-out_date": {"label": "Check-out date", "type": "date"}, diff --git a/back/backend/views.py b/back/backend/views.py index 1c368c2..b04e358 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -2,7 +2,7 @@ from rest_framework.decorators import api_view from django.http import JsonResponse from .models import * from .policy import pol -import json + # function that prints all the reports def get_reports(report_pk): @@ -97,9 +97,10 @@ def report(request): @api_view(['GET']) def reports(request): report_set = {"reports": []} - queryset = Report.objects.all().order_by('date_created') + queryset = Report.objects.all().filter(user_id=request.user.id).order_by('date_created') for i in queryset: data = { + "user_id": request.user.id, "report_pk": i.id, "title": i.title, "date_created": i.date_created, diff --git a/back/db.sqlite3 b/back/db.sqlite3 index 77fd67fd08e54caf24731ac1e3dfd3ef6ad93a2e..fe3ce3eff3b1cdb31aac803e57d19c86f8d8abe2 100644 GIT binary patch delta 3272 zcmeH}du&@*9mmf(KWA~`=H@Y9vvetQnzW6b*uK8kkJziGMz~3n)=rbS4?9oSzG-sp z*s1HRr7*Rr22`lpV0Y53P*v@ZQdL@kc7|@6(1sX7P(d~E2c>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| z#@Ns?*x5a>$xrLkU@|$a5F+$1^cCt7)`c$k7rcfaZs5&-Ntouj=#)uXb;zu|2+vX} z7tr5$ew0eiewM0&1G^G_BTrFr+GiMxs}66|Sj>40W6|k0jQhkMp+YR=1`)dGWP2gu z8ZPyHVLEDzwy!!O&C&K;*cfeh4j7}Uy}27BpN(M}ENtXRlYKQ2GIsHR#I@f}#tB`c zWh1J;Eqp;pz_-Z%wCy-0ZV`jUfjv+AtOkn{!QW^7_^ZCz;AFgcyF%pw@>e^t^v@W5PbOmPFpHykR&%z@^$m1$41Tq8(D$k$7DN~;d!^=`QE&1V?QoT z#@0_t#x5?y{=SxEeeHosXH&91LnX(D`FDqNi&Ui@n2dnEqe0+fcI7k#w6iBsV@GRX zTfC%%H>tI?tMedQoP4R0$n)ut!?9HoOgpWg_>=9-5^QA_<7RdsAI17vtS7J@!+IPO cR^a-58az&I`Aw;%72B3pY+t{#0v)FR0G_7Exc~qF From f19781a68209f5ac0ef1c569c7febb2067c8cb57 Mon Sep 17 00:00:00 2001 From: Rupika Date: Thu, 7 Feb 2019 18:13:32 -0800 Subject: [PATCH 10/11] added function that displays data values --- back/backend/policy.py | 1 + back/backend/views.py | 28 +++++++++++++++++++++++++++- back/db.sqlite3 | Bin 97280 -> 99328 bytes 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/back/backend/policy.py b/back/backend/policy.py index d40f56e..e325284 100644 --- a/back/backend/policy.py +++ b/back/backend/policy.py @@ -61,6 +61,7 @@ flight_section = Section( "departure_date": {"label": "Departure date", "type": "date"}, "return_date": {"label": "Return date", "type": "date"}, "fare": {"label": "Fare", "type": "decimal"}, + "layovers": {"label": "Transit wait", "type": "integer"}, } ) diff --git a/back/backend/views.py b/back/backend/views.py index b04e358..3ef2682 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -49,13 +49,16 @@ def get_fields(s_id): # create dict of arrays for fields field_set = {"fields": []} queryset = Field.objects.filter(section_id=s_id).order_by('number') + for i in queryset: + # function to print corresponding datatype + key, value = get_datatype(i) data = { "field_name": i.field_name, "label": i.label, "type": i.type, "number": i.number, - "value": "i.to_json()", + key: value } # append the fields to array # use copy() to avoid overwriting @@ -63,6 +66,29 @@ def get_fields(s_id): return field_set +# function to convert value into JSON +def to_json(convert): + return {"value": convert} + +# function that gets corresponding +# data type +def get_datatype(self): + if self.type == "boolean": + if self.data_bool: + return "data_bool", True + else: + return "data_bool", False + elif self.type == "decimal": + return "decimal", self.data_decimal + elif self.type == "date": + return "date", "{}".format(self.data_date) + elif self.type == "file": + return "file", "{}".format(self.data_file) + elif self.type == "string": + return "string", "{}".format(self.data_string) + elif self.type == "integer": + return "integer", self.data_integer + # API Endpoints @api_view(['POST']) diff --git a/back/db.sqlite3 b/back/db.sqlite3 index fe3ce3eff3b1cdb31aac803e57d19c86f8d8abe2..9b7a3db3c49816018aeeb88b745028bf5b925f37 100644 GIT binary patch delta 1215 zcmZvcUq~EB9LMK3ztuZE?>w!StC(mKXo-sE&KU3Z4q5_-#grO@wrMm~*Skq_sC(z$ zo_}JZ27CyGQp1)^p{Y${8YQ-1dZb684`=y zKg-N-XMW$`%y)KXqhRJ-;art_kr1MZN4E2OLa=zff3?^bEic7d7|`N_Oi%O~ES)k; zzjesm+k=~&{&|CC7`VC#7*K$E;fOZ!k zKy+GiO7e`&$Z5$*o9Zda3CVHEF`MC0$*iO)nUOSXhDH_?tDr=|hXkMEpZEwL=DZ)@ zM>~do>(M9MN+_<|h4tezT+ewgKEPtpJGNh-XYbdS6a_2roaMN()2g2<&IPX=!D@T5 zKPnlKR3*cbA?xa5uSn=6cnfDShTaA561toG4&vMAgndU2v~^k6mtL~c%N4oU^34^m zf@`(_%@%-8ur0s_C{6 z59r_nf4*Z#1Qn6s%L~I0!LvS0pIhgiFaA1Qy_3{2o8VE>!4! zI!|@l3>#2RekUJ@aLbm=&G#O|LwwFEr<3e*yPe=`jiva^7(_}!Es3n5naPyisq^|V zXy-f)ll1?}as|bQEHdaJA>hB5P{Ttb@CRSXKnD*d;4n`a(DUl1K1PI|ChEl7a1Sm( zE4avA@)=>`aJtY#zde7z$D=0H(eNqW!Jvwt$U>=Cjh|%k!G@&Xmk^ouPVgEAFIUn8 zizkP*p{77kZ3r|q1VU;&l`++E{yu}cvgeahSyRqZ$M~ggXm+W#*!EEmc?nQ&4!nW4+-wV_CszjhSr%fbnk)(kUiFu7i{$=kC~$pbx5S{^o-2yDvR z+){qH2WlMQ^w=?h2H))YI#@1!B>if(Ou<7qyh zhFV9&t|~SuqpwG{qRkl(d8O#Z$?fPeG(D3vcaCXEk;G&tnDL*AhO~*)C^Irw$3c-+ zDHLWC|AAF{nHJ+b^opB*5b$hmRN6`LKlj*2=x+&Ix99hx|Aig7u;W({vF?7_=knXf e3V4Iyja=FG&#|O)%0mXFthQ-+0}7(H{C@y53_=?K delta 940 zcmZuuO-NKx6u#%3`5))UY1F{-e;OUqW=xz$sg#~dNTXzinmRt6XZ|tscs`|#FqI28 zmG%}_NXpPmsD(9)iB=M>DhgUfi`vyrkU~UTbf2ghbT8-Q-t+sNa}raA#FlphYnm)jf;6^8TW3|zu1O3&J5-eAEhG(?`@8=OR*yT9OEM)lG1X{b%|&sJBQ9Bwi{(#6Vd;s*CH@+b79m44bn}CPHK5&}iV}c2Z}itJfjusEm%uf-)G7h5PN~640;h;G-3zkaujq zeSA&2*!v%0d~#{E0zOmlgjV5HEq$!8@dQP189kcjObu-o!RPk$4TycirGv3ZR8Yjw zdB)zXvG*H2tgaY3N9SemHSW2^$CO>ainDf72pNoVzRhNW!povECdcx$6sSSDKM*SQ zmzVm3Me?p`HwxE4IMjm6Su_|^L^-zGpDK*9t_S_us=99n`}BGL6(89J1|?l`{ov&-jg6~^=j?% S7xq0W4{yPIu!W@?p!);)f&EDU From f8b6d665c7a0f609da7a074713529d8bc49dd263 Mon Sep 17 00:00:00 2001 From: Rupika Date: Thu, 7 Feb 2019 18:21:57 -0800 Subject: [PATCH 11/11] changed the data_values to display as just "value" in the JSON data dict --- back/backend/views.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/back/backend/views.py b/back/backend/views.py index 3ef2682..ff7facf 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -52,13 +52,13 @@ def get_fields(s_id): for i in queryset: # function to print corresponding datatype - key, value = get_datatype(i) + value = get_datatype(i) data = { "field_name": i.field_name, "label": i.label, "type": i.type, "number": i.number, - key: value + "value": value } # append the fields to array # use copy() to avoid overwriting @@ -75,19 +75,19 @@ def to_json(convert): def get_datatype(self): if self.type == "boolean": if self.data_bool: - return "data_bool", True + return True else: - return "data_bool", False + return False elif self.type == "decimal": - return "decimal", self.data_decimal + return self.data_decimal elif self.type == "date": - return "date", "{}".format(self.data_date) + return "{}".format(self.data_date) elif self.type == "file": - return "file", "{}".format(self.data_file) + return "{}".format(self.data_file) elif self.type == "string": - return "string", "{}".format(self.data_string) + return "{}".format(self.data_string) elif self.type == "integer": - return "integer", self.data_integer + return self.data_integer # API Endpoints