From 186a06767c419fbd081dc5fcf18798f069d5a0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Tue, 26 Mar 2019 09:31:26 +0300 Subject: [PATCH] Done receiveing user data Made some changes to the user_data.json data format --- .../java/gq/yigit/mycity/MainActivity.java | 39 +++++++++++------- .../api/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 153 bytes server_side/api/app.py | 23 ++++++----- .../login/__pycache__/__init__.cpython-37.pyc | Bin 159 -> 0 bytes .../login/__pycache__/login.cpython-37.pyc | Bin 884 -> 0 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 161 bytes .../__pycache__/rating_system.cpython-37.pyc | Bin 0 -> 3121 bytes .../__pycache__/user_info.cpython-37.pyc | Bin 0 -> 2512 bytes .../modules/__pycache__/utils.cpython-37.pyc | Bin 0 -> 702 bytes .../__pycache__/voting_system.cpython-37.pyc | Bin 0 -> 3472 bytes server_side/api/modules/databases/users.json | 17 +++++--- server_side/api/modules/rating_system.py | 4 +- server_side/api/modules/user_info.py | 27 +++++++----- server_side/api/modules/voting_system.py | 4 +- .../__pycache__/__init__.cpython-37.pyc | Bin 167 -> 0 bytes .../__pycache__/rating_system.cpython-37.pyc | Bin 2878 -> 0 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 163 -> 0 bytes .../__pycache__/user_info.cpython-37.pyc | Bin 2082 -> 0 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 167 -> 0 bytes .../__pycache__/voting_system.cpython-37.pyc | Bin 3087 -> 0 bytes 20 files changed, 69 insertions(+), 45 deletions(-) create mode 100644 server_side/api/__pycache__/__init__.cpython-37.pyc delete mode 100644 server_side/api/login/__pycache__/__init__.cpython-37.pyc delete mode 100644 server_side/api/login/__pycache__/login.cpython-37.pyc create mode 100644 server_side/api/modules/__pycache__/__init__.cpython-37.pyc create mode 100644 server_side/api/modules/__pycache__/rating_system.cpython-37.pyc create mode 100644 server_side/api/modules/__pycache__/user_info.cpython-37.pyc create mode 100644 server_side/api/modules/__pycache__/utils.cpython-37.pyc create mode 100644 server_side/api/modules/__pycache__/voting_system.cpython-37.pyc delete mode 100644 server_side/api/rating_system/__pycache__/__init__.cpython-37.pyc delete mode 100644 server_side/api/rating_system/__pycache__/rating_system.cpython-37.pyc delete mode 100644 server_side/api/user_info/__pycache__/__init__.cpython-37.pyc delete mode 100644 server_side/api/user_info/__pycache__/user_info.cpython-37.pyc delete mode 100644 server_side/api/voting_system/__pycache__/__init__.cpython-37.pyc delete mode 100644 server_side/api/voting_system/__pycache__/voting_system.cpython-37.pyc diff --git a/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java b/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java index 03782af..935cd2d 100644 --- a/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java +++ b/MyCity/app/src/main/java/gq/yigit/mycity/MainActivity.java @@ -2,6 +2,7 @@ package gq.yigit.mycity; import android.content.Context; import android.content.DialogInterface; +import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; @@ -19,9 +20,7 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.widget.EditText; import android.widget.Toast; -import gq.yigit.mycity.tools.FileActions; -import gq.yigit.mycity.tools.WebRequest; -import gq.yigit.mycity.tools.responseListener; +import gq.yigit.mycity.tools.*; import gq.yigit.mycity.voteFragment.VoteFragment; import gq.yigit.mycity.votesFragment.VotesContent; import gq.yigit.mycity.votesFragment.VotesFragment; @@ -30,18 +29,20 @@ import org.json.JSONObject; import java.util.HashMap; -import static java.security.AccessController.getContext; - public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, VotesFragment.OnListFragmentInteractionListener, MainFragment.OnFragmentInteractionListener, VoteFragment.OnFragmentInteractionListener, - responseListener{ - - public static Context cntxt; - public static JSONArray userData; + responseListener, + imageListener { + + public Context cntxt; + public static JSONObject userData; + public static Bitmap userAvatar; + private JSONArray receivedData; + private String url; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -64,9 +65,10 @@ public class MainActivity extends AppCompatActivity drawer.addDrawerListener(toggle); toggle.syncState(); FileActions file_manager = new FileActions(); - String url = file_manager.readFromFile(cntxt,"server.config").trim(); + url = file_manager.readFromFile(cntxt,"server.config").trim(); HashMap request = new HashMap<>(); - request.put("a","b"); + request.put("username","efe"); + request.put("password","12345"); WebRequest login_manager = new WebRequest(url + "/login/",false,request); login_manager.addListener(this); login_manager.execute(); @@ -175,14 +177,23 @@ public class MainActivity extends AppCompatActivity public void receivedResponse(boolean success,String response){ if(success) { try { - userData = new JSONArray(response); - if(!(boolean)userData.get(0)){ + receivedData = new JSONArray(response); + if(!(boolean)receivedData.get(0)){ Toast.makeText(cntxt,"Please login again!",Toast.LENGTH_LONG).show(); + }else{ + String user_data_temp = receivedData.get(1).toString(); + userData = new JSONObject(user_data_temp); + Log.i("[INFO]",userData.toString()); + ImageDownload avatar_downloader = new ImageDownload(); + avatar_downloader.addListener(this); + avatar_downloader.execute(url + userData.get("avatar")); } }catch (Exception e){ Log.e("[ERROR]","Cannot receive userdata"); } } } - + public void imageDownloaded(Bitmap img){ + userAvatar = img; + } } diff --git a/server_side/api/__pycache__/__init__.cpython-37.pyc b/server_side/api/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..74958761075c019ad3d9157ff3570888c0578b39 GIT binary patch literal 153 zcmZ?b<>g`kg5rRQF(CReh=2h`Aj1KOi&=m~3PUi1CZpd~vm6}{qtRI}4SX2`4o0ylFo|>DQSE65>T2z)=6knW~lB%Crkf|RZpP83g a5+AQuP') - api.add_resource(voting_system.Vote, '/vote', '/vote/') + api.add_resource( voting_system.Votings, '/votings', '/votings/' ) + api.add_resource( voting_system.Voting, '/votings/' ) + api.add_resource( voting_system.Vote, '/vote', '/vote/' ) - api.add_resource(rating_system.Ratings, '/ratings', '/ratings/') - api.add_resource(rating_system.Rating, '/ratings/', '/ratings//') - api.add_resource(rating_system.Rate, '/rate', '/rate/') + api.add_resource( rating_system.Ratings, '/ratings', '/ratings/' ) + api.add_resource( rating_system.Rating, '/ratings/', '/ratings//' ) + api.add_resource( rating_system.Rate, '/rate', '/rate/' ) - api.add_resource(user_info.Users, '/users', '/users/') - api.add_resource(user_info.User, '/users/', '/users//') - api.add_resource(user_info.Login, '/login', '/login/') + api.add_resource( user_info.Users, '/users', '/users/' ) + api.add_resource( user_info.User, '/users/', '/users//' ) + api.add_resource( user_info.Login, '/login', '/login/' ) app.run(host='0.0.0.0', port=5000, ssl_context=context) diff --git a/server_side/api/login/__pycache__/__init__.cpython-37.pyc b/server_side/api/login/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index d639695b92eddada8073263da65132ce9f1e58ed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 159 zcmZ?b<>g`k0?vigV?gv{5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o6v5KO;XkRlhPb zJu@X=zn~~TD>b>KSU)&7v8W{8H!&|UJvBEquSCB%wWut$D84u|B~?GMAX7glKRq)~ gKR!M)FS8^*Uaz3?7Kcr4eoARhsvXFN&p^xo028|?kN^Mx diff --git a/server_side/api/login/__pycache__/login.cpython-37.pyc b/server_side/api/login/__pycache__/login.cpython-37.pyc deleted file mode 100644 index 676917d241bc1c6f6b18fa5f6df0cd15ca96b47c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 884 zcmYjP&2H2%5Vjp>ll{qd+b+;o*vl>tfKUMe7pO#g07XcVyY}v8N#fK_kh+4?_P_;k z=-~1tN^H|l3kJ5lOEj2o&QQN(_#*VYz7`d zdj@6?04lPkpJ~ND(JjSN!6AAw@r(yC$Awv1=a(ieDqzj6$`;N8(m#la;D>+DXDgkn z*=4#+rJj{WuhqP=v$I^7DtRpmu~fM#su`&Gs7zv0sb-=~XBm=eaavwFUTRw*8_NL* z>(EWF;XTE`3CIYOq!77E64y(TT+2Gc`5;LyYLT@Ovj;~TT6bWGdm+F+m__9wZPu7E z7ip0sn@&q)6Wq|+1P`apmwq`U1a+@~1(Gz?0ew}p$E zjl@827jl&@Aq}iYg$1^RYH{Gq q=Dv9^rY`O%#=aPo?ZQWGp&n!N?GZpo;bS8@=ID>;*c*i*9kT!5XW%XX diff --git a/server_side/api/modules/__pycache__/__init__.cpython-37.pyc b/server_side/api/modules/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..97d8b24cc4a4c5159cda695194fce95ca9107071 GIT binary patch literal 161 zcmZ?b<>g`kg23G~V?gv{5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o6vDKO;XkRlhPb zJu@X=zn~~TD>b>KSU)&7v8W{8H!&|UJvBEquSCB%wWut$D84u|B~?GMAX7g#KczG$ ewOBtsJ~J<~BtBlRpz;=n4MfxqWXES9W&i-IBq`Pa literal 0 HcmV?d00001 diff --git a/server_side/api/modules/__pycache__/rating_system.cpython-37.pyc b/server_side/api/modules/__pycache__/rating_system.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7dcaf9467287d410f554cddd7a3d0a21e0ee6de6 GIT binary patch literal 3121 zcmb7G&2JmW6`$EJlB<<0%d$QkyJ3^YDN|Hbd#jxcy9jlZ@>LFM*kt^;%Q-UA5Fi*852zK0gLON#~i#faB??xInB8PFZW|V58}Y` z-k^~;<7VE9TX`6VoJn8Ko$)x5Eg7Mom#n`qxhA9jqVPp#LXRzht5%!Y`NzW%JC9*TBz-2z+Gub@20I z0sMmHZ^=1v?TPbeuI|eD$!l^=EQ;&rxS!?L#ge!&<8Fy%ano{9|F&2Wt77d-2RG;Y zth4@{EV$d@l|M4sKzE$V|HUBHPpXEJPe)Rlj$1YNq%KFQCoA{CFsuCZpj0MqiPWSA zsg`;isnle}k>2R*vKWUWEmb|PxayIDi^sv>KAOG_A{n_Rb_5sB7c6##D?Id`@Nux9 zYV6fQd+?}z=w)g@L(@wj^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oK*d?#%8MtnXk%!1}yx^}Vah`4@jb4Oq&Iy#qjk z2qbm$ykVItuBifGwR{X#MeaCle8Qy#_7$jG%R52|?|Hk|k@&(&7YSxketu&C-Xe)% zg92y)%1udTna+_{p2w+6NG<{~b|;I9%*>%kVh+gsMye6#xYhA5gY2beC6V!03Y*vP eHBzWE_Ytep8T1xC2mYF2^+vr?Ujz^0$NmD3c2;8m literal 0 HcmV?d00001 diff --git a/server_side/api/modules/__pycache__/utils.cpython-37.pyc b/server_side/api/modules/__pycache__/utils.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e7a9c8c43579962d307cc93046f90e2ca3453418 GIT binary patch literal 702 zcmZ8f&59F25U%Q(OlG5TK^9clgLs>ZbJCNDsNl&U z76*$946#@U5)@s+BBGc^Y-2j2F{PKd7!l4Pn_O`%%u4PZj<+$(3l?*mm4zJ+uoHXO z<1X3**WfIR-MB7H-Kdp|T6*LX*_Ay>cT~#@Qk66|Lx<)&=rQ;B{VK2fR_0q(DeCi$ z?$@%kCZD&3w#(N=S5&fOQM~*i85$AUb7-a0eFG!baT|z3N<|i;nu%jmx@Mr8F)vR;#XZ$Au}CS~mS>smsDhmoV$f z8ZJ*7*;TgwANh?+c08Mv4E>mqTr+r={S5UjZxVgNM*FpEPimkyjHUf=f3@^m)q#=p U$ze%P{mU`_v8KqMNTYQ82U)tAIsgCw literal 0 HcmV?d00001 diff --git a/server_side/api/modules/__pycache__/voting_system.cpython-37.pyc b/server_side/api/modules/__pycache__/voting_system.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6f48cb36c5847a4f86d1b1e1100d0cb4de2dcc9d GIT binary patch literal 3472 zcmb7G&2t;K6$kcC}}IE3sWR9?pt@ z3Rt=pL!RVAFPXM8y<{c_>C%~Adh98G39dc)U&yJyhovaVRu9>oeZT|WJ^=6I_wei4 z*)qd(?VGPYKL{E7FEOW237z-x>32C}f(hPb&AjDJ4&LcHiQ9BJjk#Sf@tb}UGy}_f z-9l1q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|p*3JBv45BU<@7jO?w9hUQb5VUVY z+m9il>O>ku=-+et&Kz|e6Tio2bEL=>@!#1^9@dsqARxpi|63>h2OUCuN_>m@)VJ;t z?h0H61otvBxTF3(;#n}lobXoJlY;suY6MC9N0aqug38%FI?YylKm0>bPzS9En*}Xf}PX=0diXlS~IDUvvi!!8g!stMAdsn?!yBGMv5LRWcHXRnjMhS3ko_7lTvRW-U0W8su?Z>1B#i%#`;4 zXRX~stc5!s-OO^#`YGxDA(0ItZxeZo$U7htTv9h^zy|QosrMryHqg$Zjl%FDK21r) zf-+w~5LfsduiD<4Q^Y$g-p9VbYass&3LlVaItT)pcmlE{ihHfrusFFS>0#-#*BGu$ zyPGhJs*5cg}ND_nG2meu6D3&YFA= fXm>)V!WSK?Dhqr86=l(Wl^d0?vRsC5@jCwlpbP=_ literal 0 HcmV?d00001 diff --git a/server_side/api/modules/databases/users.json b/server_side/api/modules/databases/users.json index 58ac429..e96dd26 100644 --- a/server_side/api/modules/databases/users.json +++ b/server_side/api/modules/databases/users.json @@ -1,16 +1,23 @@ -[ - { +{ + "efe":{ "id": "9vard12ty0ad2yvwp3q53rsf3h43r2vq", - "username": "efe", "realname": "Efe Aydın", "avatar": "img/user1.png", - "password": "e10adc3949ba59abbe56e057f20f883e", + "password": "827ccb0eea8a706c4c34a16891f84e7b", + "email": "efeaydin@mycity.com", "stats": { "bus_usage_week": 1, "bus_usage_month": 5, "bus_usage_year": 67 }, + "daily_electricity_usage": [ + 10, + 5, + 5, + 6, + 7 + ], "points": 50 } -] +} diff --git a/server_side/api/modules/rating_system.py b/server_side/api/modules/rating_system.py index be907ee..2410675 100644 --- a/server_side/api/modules/rating_system.py +++ b/server_side/api/modules/rating_system.py @@ -1,7 +1,7 @@ import os import json -from . import utils +from api.modules import utils from flask import Flask, request from flask_restful import Resource, Api, abort @@ -74,7 +74,7 @@ class Rate(Resource): note=& # ADDITIONAL rater_id= """ - if utils.find_by_id(users, request.args['rater_id']): + if utils.find_by_id( users, request.args[ 'rater_id' ] ): rating_id = int(request.args['rating_id']) score = int(request.args['score']) if 0 >= score >= 10: diff --git a/server_side/api/modules/user_info.py b/server_side/api/modules/user_info.py index 4ff09c5..31f74de 100644 --- a/server_side/api/modules/user_info.py +++ b/server_side/api/modules/user_info.py @@ -1,7 +1,7 @@ import os import json -from . import utils +from api.modules import utils from flask import Flask, request from flask_restful import Resource, Api, abort @@ -29,7 +29,7 @@ class Users(Resource): 'username': args['username'], 'realname': args.get('realname'), 'avatar' : args.get('avatar'), - 'password': utils.md5(args['password']), + 'password': utils.md5( args[ 'password' ] ), 'stats': { 'bus_usage_week': 0, 'bus_usage_month': 0, @@ -48,7 +48,7 @@ class Users(Resource): class User(Resource): def get(self, user_id): try: - user = utils.find_by_id(users, user_id) + user = utils.find_by_id( users, user_id ) if not user: raise Exception('User not found!') del user['password'] @@ -63,18 +63,23 @@ class Login(Resource): username=& password= """ + #Password for efe is 12345 args = request.form - print(args) username = args['username'] - passsword = utils.md5(args['password']) - for user in users: - if user['username'] == username: - if user['password'] == passsword: - return {'message': 'Login successful!', 'id': user['id']} + passsword = utils.md5( args[ 'password' ] ) + + if not username in users: + return [False,{}] + + user = (users[username]).copy() + if user['password'] == passsword: + user.pop("password") + return [True,json.dumps(user)] + else: + return [False,{}] + - return {'error': 'Wrong password!'} - return {'error': 'User not found!'} if __name__ == '__main__': api.add_resource(Users, '/users', '/users/') diff --git a/server_side/api/modules/voting_system.py b/server_side/api/modules/voting_system.py index 704185d..05f6ee8 100644 --- a/server_side/api/modules/voting_system.py +++ b/server_side/api/modules/voting_system.py @@ -1,7 +1,7 @@ import os import json -from . import utils +from api.modules import utils from flask import Flask, request from flask_restful import Resource, Api, abort @@ -93,7 +93,7 @@ class Vote(Resource): voter_id = request.args['voter_id'] voting_id = int(request.args['voting_id']) - 1 - if utils.find_by_id(users, voter_id): + if utils.find_by_id( users, voter_id ): if voter_id not in votings[voting_id]['voters']: vote_id = int(request.args['vote_id']) votings[voting_id]['votes'][str(vote_id)]['votes'] += 1 diff --git a/server_side/api/rating_system/__pycache__/__init__.cpython-37.pyc b/server_side/api/rating_system/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index 50508aac74b8a1b3ba7dbc715e59d41e0caaa7c1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 167 zcmZ?b<>g`kg5rRQF(CReh=2h`Aj1KOi&=m~3PUi1CZpd~vm6}{qtRI}4SX2`4o0ylFo|>DQSE65>T2z)=6knW~lB%Crkf~pkSdy8S o9$#EpT#}lrA0MBYmst`YuUAlci^C>2KczG$)edCSXCP((0GBu{8vppw-qhan{`rcXr%1 zCOM@CBvcR*5|x>Lhx?sR9EG18d1r~O=MRX81<;*}9?o&Fl0a+|D^d*n;PELM0* zSbHvde6{nHInTiAy;CC!?anO}r{`XDO^{;jjzV z-%o@bl!Y&YxRWk-(sv|0>)SymU`f3vk}hw{w7wDfLV92MvEShlk7YgO;t>~K8Zch>dqF*qo|kT?l1In2 z<=*xSXEh8`*-oNfqXLgfF&>sRcw-!^A7%Ze~_) zINY;9kC_fGrqQ(pf@qdyYlG4e_mlXVFpc3*=@2lGqzh?~n$-6owu@v}+tDD(D!xO5 z=_80d^u~yG2s59XySmhe<__2?k(MlU?O{Bf4ZYp=^1TMK7a`> zZbA{+o{F~TWsc`X3G0U(#%0fY*!M%sgXgLD5H;|5j1$ zTmLVo07{I^%6Hbra={CGbgi(v0)y?cRE$ssX4oK9{Ul(Q=|jNqh%y5y@f#9r_kh@u zA({ds5&Q}XA1vnX-S2l@mhd#bBwhXlY7f$Aav>5?)AOWZO=T8l(w8+&r9fN)+mUxy zuZ_w55L$|xBvhkii1on9AA?2S1TI2O6YrvU4+Y+H#Lr<2--n40peeGjsX+aeBWS?0 z`O9nn5AY|6q+MY0B}K(!4Jsdq8DhAj8AK-!OtHcYkc}9Q$JmiNGnusqam9Oq844o` zoL~ZH*q8@aTp~l@h2s|B7JHEZv*^ruo^yvSi(O|}LatyX;EwW`JEprcaIb+!-y6INZ51D(P!(Tq;Ja$)HKW6Ub z6*#fLvjV1Agxdgi>cF}TV}W=&&NiZo_9a|M1r~R+R)K>qmWpx2MVv*%=Fn2C^E#?{ zc#E?r-az4^coW4r6z5UAh2jE;G125GpX@`tjq?hkhd4z5UxAk5wun7Vr)iZs0R0MG zfD#y!jEz8i)e^uG{|H^H!lwdtWT(gvV$U1c?iQR&GVruAA^k)ALOZUaaLtPB>)4Q8DZkHoOzH)RORRIUiKM7@8j<`(T|U0W0I20 hUd>s%fk;d-<-oyOh0bZ%SD~+5s1zzy8*&9d?O$G1aX|n8 diff --git a/server_side/api/user_info/__pycache__/__init__.cpython-37.pyc b/server_side/api/user_info/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index 495d818e857b80e10d337187fa37918f1709208a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmZ?b<>g`k0?vigV?gv{5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o6v9KO;XkRlhPb zJu@X=zn~~TD>b>KSU)&7v8W{8H!&|UJvBEquSCB%wWut$D84u|B~?GMAXC2-C=j2S hmzJ*|52P|n;^XxSDsOSvt%=<07EoN$_wu;MhNFlH&stkBBr(55(VrB3FCZsvtv=7&Bd!V z0q{9d7i8F&HAOHy!|emcoqhIOD{KimJ1bfTG@Sndtb9lAkbC57!d>n?A>0%0z7;OO z*ylAE*UIstsPW(dlYfc1*^*e`bG&|FfkhlG@&<2~qhPqq&+ryM`;@^A=?3Y{zks)p zeuo+7t29;*j3>pzu~52W8UKz@#aIr6v2KhKPWqJF($W>|a1v^FXR&n%pG&bdOH)u2%oG z?GEhP!0m4V*&=kb=vM6P?Fa7V~UC0z94QPM*T zQIc;KCsKE``!ZNf6Qu`5Hd87!9cydeG1U1Hj<0vS=D>%`$eKx5bD?WA^x(gp&dUy(gCPVP7X4={Zcby}9Y|6lK z4Ba=gxpe@}1a2Qt?v$VV+yd@BclRu9&73LhphUac8~U@F4u*5w2MpH$!^?ZNt`8g9 zn%X?zb58+@faH3G$mTIv);e)?eV^N2XxA7s}+yNGCh6Y3j||{3F9AWG;VcD;#$WF zoA<{m8Y>8Y^hk&Y;hB?hR^)p7)eXBMmL2y5X>tkmF9R`-(y>;?9TiEg)$2L+=!K28 zsBx2=1IGHDrnK;oy;;c2SgFV*f=Djlq#KV$BIm{~fEiXOV~=9JZR{baHWsX!nk)(( z9nNCf+I*aiI*vSBYK`TVG9LOjO1Q+_Gj#L6AhSn>(krl5<~H$MT4#*9)TcghkeF`; zY=vH6lc2&L9_V)*<3|w&DT+)GMOneeDa!RIdN{7a7e(buI&fJi35UPf|Ugv#_Tee)U2E4(cMSJ%Pq6Cdqi;pl_vkMP*XNIpS=xOhd& zi6gtP@G11N{Pg`kg5rRQF(CReh=2h`Aj1KOi&=m~3PUi1CZpd~vm6}{qtRI}4SX2`4o0ylFo|>DQSE65>T2z)=6knW~lB%Crkf~pmUy_-Z o9$#EpT#}lrA0MBYmst`YuUAlci^C>2KczG$)edCSXCP((0GdK9EdT%j diff --git a/server_side/api/voting_system/__pycache__/voting_system.cpython-37.pyc b/server_side/api/voting_system/__pycache__/voting_system.cpython-37.pyc deleted file mode 100644 index 96184de060ce756c59b4539921c7e3a53ed216a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3087 zcmb7GTW=dh6rS0e*SExN?gddREolwK4g!HxrKW`f0*ZS{TZ(D5T0E0Ny9^THD~6`%$}J!=X~Gn$Hiifz?0qm z{qA2`LjFNz?*W}$gcAP?f)PeLq?y#TNkKO{Mrbz8&}v!~`^}CWI!!0cG&7;wbSdE` z&+gD>j%Rod>O3!S(k_msc&-Jp;4War#>zHp!6OTgHiuED?}YOG8U@ zi7@LA>sRBU1!inz1WZ|7Kjg|{JZ>p72sbO1zzh(WAR>>V0OC&q-Z84HiaruW>_qY6 zR_%Ti^4eCg8L+6<6H%MDWL#SheIdQC{jR^sL*A9On2SeTcyYjZ&F=-Z#Cu-66-yo- z)T+I$7rC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