From 6ae2d013f4227c185a480386705a9bfc3b725abb Mon Sep 17 00:00:00 2001 From: Ashwath7349 <116176439+Ashwath7349@users.noreply.github.com> Date: Tue, 23 May 2023 09:10:47 +0530 Subject: [PATCH] Add files via upload --- .../EmpManagement/EmpManagement/__init__.py | 0 .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 212 bytes .../__pycache__/settings.cpython-310.pyc | Bin 0 -> 2071 bytes .../__pycache__/urls.cpython-310.pyc | Bin 0 -> 332 bytes .../__pycache__/wsgi.cpython-310.pyc | Bin 0 -> 627 bytes Homework/EmpManagement/EmpManagement/asgi.py | 16 +++ .../EmpManagement/EmpManagement/settings.py | 92 ++++++++++++++++++ Homework/EmpManagement/EmpManagement/urls.py | 8 ++ Homework/EmpManagement/EmpManagement/wsgi.py | 16 +++ .../__pycache__/unittest_api.cpython-310.pyc | Bin 0 -> 1811 bytes Homework/EmpManagement/docker-compose.yml | 29 ++++++ Homework/EmpManagement/dockerfiles/Dockerfile | 13 +++ Homework/EmpManagement/employees/__init__.py | 0 .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 208 bytes .../__pycache__/admin.cpython-310.pyc | Bin 0 -> 540 bytes .../__pycache__/apps.cpython-310.pyc | Bin 0 -> 420 bytes .../__pycache__/models.cpython-310.pyc | Bin 0 -> 890 bytes .../__pycache__/urls.cpython-310.pyc | Bin 0 -> 351 bytes .../__pycache__/views.cpython-310.pyc | Bin 0 -> 2634 bytes Homework/EmpManagement/employees/admin.py | 9 ++ Homework/EmpManagement/employees/apps.py | 5 + .../employees/migrations/0001_initial.py | 27 +++++ .../migrations/0002_alter_employee_dept.py | 18 ++++ ..._address_alter_employee_emp_id_and_more.py | 43 ++++++++ ...emove_employee_id_alter_employee_emp_id.py | 22 +++++ .../employees/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-310.pyc | Bin 0 -> 991 bytes .../0002_alter_employee_dept.cpython-310.pyc | Bin 0 -> 711 bytes .../0002_remove_employee_role.cpython-310.pyc | Bin 0 -> 510 bytes ...r_employee_emp_id_and_more.cpython-310.pyc | Bin 0 -> 846 bytes ..._employee_address_and_more.cpython-310.pyc | Bin 0 -> 1128 bytes ...e_id_alter_employee_emp_id.cpython-310.pyc | Bin 0 -> 711 bytes .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 146 bytes Homework/EmpManagement/employees/models.py | 30 ++++++ .../employees/templates/index.html | 13 +++ Homework/EmpManagement/employees/tests.py | 3 + Homework/EmpManagement/employees/urls.py | 8 ++ Homework/EmpManagement/employees/views.py | 78 +++++++++++++++ Homework/EmpManagement/event_logs.txt | 2 + Homework/EmpManagement/manage.py | 22 +++++ Homework/EmpManagement/unittest_api.py | 53 ++++++++++ 41 files changed, 507 insertions(+) create mode 100644 Homework/EmpManagement/EmpManagement/__init__.py create mode 100644 Homework/EmpManagement/EmpManagement/__pycache__/__init__.cpython-310.pyc create mode 100644 Homework/EmpManagement/EmpManagement/__pycache__/settings.cpython-310.pyc create mode 100644 Homework/EmpManagement/EmpManagement/__pycache__/urls.cpython-310.pyc create mode 100644 Homework/EmpManagement/EmpManagement/__pycache__/wsgi.cpython-310.pyc create mode 100644 Homework/EmpManagement/EmpManagement/asgi.py create mode 100644 Homework/EmpManagement/EmpManagement/settings.py create mode 100644 Homework/EmpManagement/EmpManagement/urls.py create mode 100644 Homework/EmpManagement/EmpManagement/wsgi.py create mode 100644 Homework/EmpManagement/__pycache__/unittest_api.cpython-310.pyc create mode 100644 Homework/EmpManagement/docker-compose.yml create mode 100644 Homework/EmpManagement/dockerfiles/Dockerfile create mode 100644 Homework/EmpManagement/employees/__init__.py create mode 100644 Homework/EmpManagement/employees/__pycache__/__init__.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/__pycache__/admin.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/__pycache__/apps.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/__pycache__/models.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/__pycache__/urls.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/__pycache__/views.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/admin.py create mode 100644 Homework/EmpManagement/employees/apps.py create mode 100644 Homework/EmpManagement/employees/migrations/0001_initial.py create mode 100644 Homework/EmpManagement/employees/migrations/0002_alter_employee_dept.py create mode 100644 Homework/EmpManagement/employees/migrations/0003_alter_employee_address_alter_employee_emp_id_and_more.py create mode 100644 Homework/EmpManagement/employees/migrations/0004_remove_employee_id_alter_employee_emp_id.py create mode 100644 Homework/EmpManagement/employees/migrations/__init__.py create mode 100644 Homework/EmpManagement/employees/migrations/__pycache__/0001_initial.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/migrations/__pycache__/0002_alter_employee_dept.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/migrations/__pycache__/0002_remove_employee_role.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/migrations/__pycache__/0003_alter_employee_address_alter_employee_emp_id_and_more.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/migrations/__pycache__/0003_delete_role_alter_employee_address_and_more.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/migrations/__pycache__/0004_remove_employee_id_alter_employee_emp_id.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/migrations/__pycache__/__init__.cpython-310.pyc create mode 100644 Homework/EmpManagement/employees/models.py create mode 100644 Homework/EmpManagement/employees/templates/index.html create mode 100644 Homework/EmpManagement/employees/tests.py create mode 100644 Homework/EmpManagement/employees/urls.py create mode 100644 Homework/EmpManagement/employees/views.py create mode 100644 Homework/EmpManagement/event_logs.txt create mode 100644 Homework/EmpManagement/manage.py create mode 100644 Homework/EmpManagement/unittest_api.py diff --git a/Homework/EmpManagement/EmpManagement/__init__.py b/Homework/EmpManagement/EmpManagement/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Homework/EmpManagement/EmpManagement/__pycache__/__init__.cpython-310.pyc b/Homework/EmpManagement/EmpManagement/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9962d666aa6ad53fe4d0a7ee2572a11dee867b1f GIT binary patch literal 212 zcmd1j<>g`kf)%MjDIoeWh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o5j}KO;XkRllGp zF{?Z=N8cr}B+)f5Ju@#gwJ0+$T{k?xD7!c#zraX8EVC>%J25XYFC{U)IJLMqGe6HL z-Xtu*$iO++z|1H<0BVA3Zh#xDla}hGcU6wK3=b&@)n0pZhlH>PO2Tq LLB&i!f`tJ9|CBiI literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/EmpManagement/__pycache__/settings.cpython-310.pyc b/Homework/EmpManagement/EmpManagement/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a98ce56632106781a868b8f4c226a3e8e27e75bc GIT binary patch literal 2071 zcma)6OK;mo5Ef-xqUA>%KawC^JOk& z$GrA$mTec6T1%4!@n9V1B-kf#?D$Qxi~6?j1SR5A z+#5u=)L%g5f3LL zVml_iW8#AC3HCxaxWJgob{JAw9W5(?e@q<6yEKgU2tqDCw<9d4RFL>W);T9IX?(OL zo0FRj)04;I^()<2RPp*Iy}7DfL-U;y?`KP_e_OKT6&FEO%5|G}oeK;!*vXKXo zOOx^tE9U28$5`$H2=)<`hlXlem&VXc*-~00Z(}Qrf*zz6M6@U-&n986d&vlQ2Trnf z3(p9j4ls?A=R;o(mXr7HwEi0Yn zwU$xSntJl&bK1_SLwF4XSl~!wgXO6N_O$V<*D&)HP>0hx`gysB20i zgPB`@v9Y5|rjEcPNgOm=ijPu}(bV+Wc-EUU>vj^76Jw4dN4T z;MKA3#BV;u|9IQ@t2@^k=J*NV)olTq0}n@}cO79G`=tS8Qyrs{Mj1xA@8_sw;-7v&AEQzsCLRwTi;)kj+#TL*d)%?19oT4y;irScgiz21X6acfPJP z_dCkIYE`tV3V^kSYMB~Tkp%T))z){KEXQYt37H#!T;aR3rK-B8bn1o$$eOiRQ|r|~ zGSO3DAr&9wauft{8A|DdhIS8^DT#6Uvx`xtIF6zHP&vF{()Ymdz{M{GfS@f9bHZX) vgg2L!vQj}Tz*NWzQZ{=j{wrRJi`gl@9=+m+RCg(gU>|+|h>IM7zf$%;)J??@ literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/EmpManagement/__pycache__/urls.cpython-310.pyc b/Homework/EmpManagement/EmpManagement/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c0a79f4d90e8ef7b9ed5539c4ec19830959dfb90 GIT binary patch literal 332 zcmYk2Jx;_h5QY7hP1wz@=s7_s;tQ-04J9;46zNPn3JLy+>_lkO<}}pY#w`_Bpg`CN zAx84^n@=;(lI?!KMX@f#gM5qkdusky7MtsM{4t6|5-X%}gK_di5ltJaS;H^_DkiN9F)>_^c8PfPqpkGH~z4m6mFr-XVuh2p5KoE2Q*xarf^mG~T&w8X{NH+D=| AyZ`_I literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/EmpManagement/__pycache__/wsgi.cpython-310.pyc b/Homework/EmpManagement/EmpManagement/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7d19960852d13062e2580b03fc93f0c8a863c9b0 GIT binary patch literal 627 zcmY+C!EO^V5Qe>*v?&Wk98k}`MxyIzRdGNFfk=pgXj-wQm2z>+da`lqwO4C5p}q15 zya3$bl~&@!iC5snYywg;l5LGgGymrq+rz_%pnZq;@=HL-ug2N7HaahHxgKtkOo$9* zsDnv>XG@1gYtjk`1dI09J=vCf-$L|SpUGrjhAHXp-~EiP(&30^*348+XSSk)qC6Ew zyQxzNIIR0 zveYUQURg7pV!b!0RoDusGALWD1JoKUt{j~y4Ns^8i00mx?ipj!W-gWsVRHMQDYFFw z!%pIa&F#utCZW{!w&7+gmn#e-y;CXY$w=n9X{@YjM;TcZ{7Z;=PFy*Ib z{SWU3cSk!th#h#ZOzyg!y2Ckwa9)Sj)sHqfafYvmo8nc7a&-sHQdQQ}5hhBQi5uUH~gAu~-Ss`ofEW$&~@9Q1kf8R@ZKB%Y^xARKs4^sG}Ww1van=S;2&a^{{B z3Vz+PH@yq^4(TLlr;h~#ANmvM>N_wR&T@9jez|`_kI5J0hw2GCre{>MV|Gfpb%&f& zN)CKn<2H`Jhn#F^rxwH_UGgDOYeQJa_7vm8TGQ!_>f&dS>nJPsR7)RfL*q-@Ff?dd z#xD9IH_lL|S{O@d*|b7Oi$kr#>Ta5esCd>Bi8eN_{YGR361`k&%c9WjVIiNZew>K5 z0`K-9Pqh|GM{z%G^^Z)YFVk^U2Y(_WUZXy}MQil^zhxDs3wXesFzAn>;j&e^t_&b)EXnHE8NCiIOX8`X^HC)a_Ed&KWW|HZnrmDW!v7|*w|=` z{eD&)387}A_LpfM=ZUy@g;}kZDD4RyO;1K#^!0Y5J4h0t)aBiz$a6qFE%JttvXG4; zNd{61K6>z9zB@CQ$LP@vj4#E(05DR@>+DMxBco1KMVoH)sAPy5q50X)4`AQh$lq5Hqv6aYnjVpy3WV)2e*dXoZ_VroUk*J$s z7!7E>Y%8FUI%Tg%?;*Xd>-`p3$2vk)maJhxgRh-502sm)ZtcI1TuGDD#e+qO{E+KU5Gr;34o5@o} zyM_jRyRFJ-sFCgNLL6yNoq?KB4_)C(bv~(Vgf;rfaDIoYeK~ zWL%4lv5c1T3a!vWSAruTN~0NHlsQYcMY?1>|6a(H-TSo~6zHCUvYi^Yy? S;W1t*Q(Zb(hi7o)5t9#Hd^h<3 literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/employees/__pycache__/admin.cpython-310.pyc b/Homework/EmpManagement/employees/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..998d151a19e1aa1e91779afdd20ffbabc8f0cf90 GIT binary patch literal 540 zcmYjN%}N6?5Ki{5Yg-kn_zJR@?h6#Dpm?$u@v@f?J7Y=BHfyp)de#TgqwnC8qaQ>JqcjZIiJ<$ zPHFTBVAJ}{NiFTB;C4XOW<~0A(P;?b`$E(P)*8tl3h}s>I;aPx73qU=jg}if=-9o| zE!uZxMLA6z5nSUS~WNey*_yRuuzxY^j0Qo_bvMv$|F=e&EH6?t_4 zOSxK@@!YIhtL|(>Az=tW?QBT${p&!wJ#<+<33YsKaY1dO{p)Dw9fhQPvYYKJtlQ-T LLpJ22Xq5f{&HRiO literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/employees/__pycache__/apps.cpython-310.pyc b/Homework/EmpManagement/employees/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d1dafac577c1e9b2b59f5ef014a74c1e49a307bf GIT binary patch literal 420 zcmYjOy-ve05I)B#N=qvw)D?*dDN7)7gwh10Xq-clb{4X9#vBreH$qj>#Y((@?X5F}MMYkiP+P#a?+4 zVSEc|?~727GT)zCduf(swU~#@t}qHFq;5<`LBSBHn-v_RB1TRuu|K$~tu`yA+=k@k z2p{BfVKThWYJ*C~t$6k%%&|_&C%)py|_MYx8}QH^#L2vuPfkm2;K5s#W>luv}W}GP`Oxbp&;LWDb&V5SHZo_c?gNkPHn&#o#7>05S~0I3$IgOp@vvjbd$_bL2ZCT?Wk1k%A`g z03{`F!853(@++ibb(b(kH`?3p(@OhWb~*{c_3c$Ae=$P-IIzAv1aEMg7bql=RFOH& zC?%3*>^+e!>D>_N0iCtJwlYupr=%CG(3bS54d$f;WqM(cS$1%uTaIS7JuIeq0ig3@ zs+|Mm;*ro-P&vkLnCMuEqHsje5dNu9V074^a6d0ZF##PlI5}E?7FAvrM#o4^aR0ad zWpaTukc>)_F=)*^NhQ0bnZKq7YkG)!DVeVz-_uHzK|IVGWtm05@h^i5ttAMWEe{icaKi=_=YHTd@fjZ+932jZr#OJHsBC&zR4|3+;VdvhVTJX!bKo*w z6I%|tvb#DO7eYi*`tWVgh^DMQANPD4%b6&q<&HeBgV)c{-1;LoMDEy@bEkhn%Ko)P&4>IEXuCg~<@&&KY zWk-Sx6iBWH`T#jNz4-xGv9pNyx9y1Ja>P5 z%)V_B@;7$o9~U~ep-BdU5k@o8ryWWOvzVP(eY<0WPMDK9eYfKp-Oaqd-|>y^WkJ8z zsTtkR!cNF*+-Cu+9b4ZM7P9&a!s?tpx1ZBao%!3O)i?uBq(!y!IOT_DwCn_1{UXap zoWqO8J(&+4a#`d9iT!$4irtt$C;-gHwR!F^ap^jcSLu?RM7z zJJl0_QiJv#H2FJ-J#yrXuTLz|RHR3H*2H4;m>xNU+Qb$s(=nS_IQE1LmK_3P_Gq0F z{3(ao81k1EbD4K+dE_UuO%BnjJ8|xipKly_6R+n&!+#%I0Idcsga%=L=^yzM_oOlL zUqLFLZi2;N;u?!Jv7 zI;G+Y9I)lKx*xoqcZ>scz5K%9zY6xUE(M}Z#13W`+}#EF+k0FszzX>}2!~qKp^MNKsPpRrU7^-LjulYHa$v0b zd9NF_B|2W*n(hKIwgG0k7MQ3W)Ulck%>DvpLVM(dGWv>&^{H;n>GquN%<1l&?#<}{ z7WtL35cezu@YPuZp`z@b17Mr^I`=fyz|T|zFH;SCOf~Q@)xbV$9s_THj|Fzc_*g7` zw63<_o?XmZnPQCUcx^q&vPkXoXgB2JA~eT0+Wau8avK4rIg55iQOd+SXv@>igZtZ$#7Ah|U=u+s-UXq(uHcD+8WQi} z*!w6DK&AK)r#M9})yJU88z3IhCF;@e!q0oX6pXK4fCH}SB9B!Mx;7|D90UrI-?w9ZKNDS5EbPBO^7;J7P!yx&1ydp)LvtZg}S;WJ!fA0*kOK#I>` zCNjE2cNUabK(B$sA{#GP&P_3u_AkWGgEh1G{Q;eE?PC1qsCjJ`rwfs+;xrDFd*T7k z0pl}DcYDF;>$!FQc?PO=6Xyi#4c53o&tyo&!-+ewW4I%9*YDr9=wMoynqhdT@E;LVbC ziD6-B%WAht6_5?G~@U!!FtJHFW)d%hCp7&n-U-@%geAneZQ|%Q3i8ue#OS@(?@RL xw~;_3>(%L$p-MA3H%0jHR(yd1ck^HS)xoXuz~A8Km|O(WAPrjn0vft2^k1_5T*?3d literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/employees/admin.py b/Homework/EmpManagement/employees/admin.py new file mode 100644 index 00000000..a9706f5e --- /dev/null +++ b/Homework/EmpManagement/employees/admin.py @@ -0,0 +1,9 @@ +from django.contrib import admin +from .models import Employee + +class DjEmployeeAdmin(admin.ModelAdmin): + list_display = ("first_name", "last_name", "emp_id", "address", "mobile", "dept","salary",) + list_filter = ("dept",) + + +admin.site.register(Employee, DjEmployeeAdmin) diff --git a/Homework/EmpManagement/employees/apps.py b/Homework/EmpManagement/employees/apps.py new file mode 100644 index 00000000..e1187f4f --- /dev/null +++ b/Homework/EmpManagement/employees/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + +class EmployeesConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'employees' diff --git a/Homework/EmpManagement/employees/migrations/0001_initial.py b/Homework/EmpManagement/employees/migrations/0001_initial.py new file mode 100644 index 00000000..69d2392f --- /dev/null +++ b/Homework/EmpManagement/employees/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2 on 2023-05-05 13:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Employee', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('first_name', models.CharField(default=None, max_length=200)), + ('last_name', models.CharField(default=None, max_length=200)), + ('address', models.CharField(default=None, max_length=200)), + ('emp_id', models.IntegerField(default=None)), + ('mobile', models.CharField(default=None, max_length=10)), + ('salary', models.IntegerField(default=None)), + ('dept', models.CharField(choices=[('HR', 'HR'), ('Engineering', 'Engineering'), ('Marketing', 'Marketing'), ('Planning', 'Planning'), ('Sales', 'Sales'), ('Finance', 'Finance'), ('Operations', 'Operations')], default=None, max_length=100)), + ], + ), + ] diff --git a/Homework/EmpManagement/employees/migrations/0002_alter_employee_dept.py b/Homework/EmpManagement/employees/migrations/0002_alter_employee_dept.py new file mode 100644 index 00000000..f4ce64cd --- /dev/null +++ b/Homework/EmpManagement/employees/migrations/0002_alter_employee_dept.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2 on 2023-05-06 04:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('employees', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='employee', + name='dept', + field=models.CharField(choices=[('HR', 'HR'), ('Engineering', 'Engineering'), ('Marketing', 'Marketing'), ('Planning', 'Planning'), ('Sales', 'Sales'), ('Finance', 'Finance'), ('Operations', 'Operations')], max_length=100), + ), + ] diff --git a/Homework/EmpManagement/employees/migrations/0003_alter_employee_address_alter_employee_emp_id_and_more.py b/Homework/EmpManagement/employees/migrations/0003_alter_employee_address_alter_employee_emp_id_and_more.py new file mode 100644 index 00000000..c408efb8 --- /dev/null +++ b/Homework/EmpManagement/employees/migrations/0003_alter_employee_address_alter_employee_emp_id_and_more.py @@ -0,0 +1,43 @@ +# Generated by Django 4.2 on 2023-05-09 01:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('employees', '0002_alter_employee_dept'), + ] + + operations = [ + migrations.AlterField( + model_name='employee', + name='address', + field=models.CharField(max_length=200), + ), + migrations.AlterField( + model_name='employee', + name='emp_id', + field=models.IntegerField(), + ), + migrations.AlterField( + model_name='employee', + name='first_name', + field=models.CharField(max_length=200), + ), + migrations.AlterField( + model_name='employee', + name='last_name', + field=models.CharField(max_length=200), + ), + migrations.AlterField( + model_name='employee', + name='mobile', + field=models.CharField(max_length=10), + ), + migrations.AlterField( + model_name='employee', + name='salary', + field=models.IntegerField(), + ), + ] diff --git a/Homework/EmpManagement/employees/migrations/0004_remove_employee_id_alter_employee_emp_id.py b/Homework/EmpManagement/employees/migrations/0004_remove_employee_id_alter_employee_emp_id.py new file mode 100644 index 00000000..f5110e25 --- /dev/null +++ b/Homework/EmpManagement/employees/migrations/0004_remove_employee_id_alter_employee_emp_id.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2 on 2023-05-09 12:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('employees', '0003_alter_employee_address_alter_employee_emp_id_and_more'), + ] + + operations = [ + migrations.RemoveField( + model_name='employee', + name='id', + ), + migrations.AlterField( + model_name='employee', + name='emp_id', + field=models.BigAutoField(primary_key=True, serialize=False), + ), + ] diff --git a/Homework/EmpManagement/employees/migrations/__init__.py b/Homework/EmpManagement/employees/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Homework/EmpManagement/employees/migrations/__pycache__/0001_initial.cpython-310.pyc b/Homework/EmpManagement/employees/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..34655743592f2222cb15cacdc25a3dbb3f15e4d1 GIT binary patch literal 991 zcmZ8gOK%e~5VpPB>?7#|C@oKk6H+8-$`J{nLTO76Er`NpFDo}Q**e`v@NR%`g=_u< zH~1y|246YlA0Q6EcsJ0(TDJUsGxp4U<1H2!Lq^}8{|dlm?3)GWKjPRH&GI%az<{SL z;}Oq9Bskk+Ai(*^z(GEAJ~)vB?h)%Q%*dB@g$Xm2Xj!QuFHI{e0MoK>P3OO50$Vi8 zFSHE-nmPHUxS@A2RuXuCmW^31knfu zyGHCk>AI#P$5j#cHOdOXv`1QHQcvPjoS2|Qtz@d+qv^aseO#0n=Q2YR4wNpddVe_k zN|KO_9^gQZ(~9(z@8T5mq&hJ{D(8O2lK>h^(ipQ*tf0&F5}mY?AFC8+w!@}X%9NrT z7jRT{J-SvreWBNz2<@FbQ8`jhd7`g0TyP-uDOQ%b+A#j}ROY!Qt~JEMkxa4F*Bj*R zs$AxM)HfO&J{#e@`}!tPGqAj4y#7g{`gG1Fscru$8Mm&!HBgvB+3grVt~H2b6UH$; zopFk^@5J%zu}rNmAy4J1A{9-CYQh{a?<=}i(2b_OUCVx8ADwnA(|N3tN7RsA8^Q$J zCsH@t&VF8Df^!rWf3yC~^c|a`U4Go}>7uB5Zwq}|j$|KurK+$;g4b;?duLC*x4F4_ zFP`VNF`8)m54C8Pw`lR1D`>cauZk6J$5K7lxcKh=^ncafhxB>^7|J{;HsH9fs4k*5 Zo+Z`n?$WKsf6$2ZklR2u;)+;vegnRI4{`ti literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/employees/migrations/__pycache__/0002_alter_employee_dept.cpython-310.pyc b/Homework/EmpManagement/employees/migrations/__pycache__/0002_alter_employee_dept.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..08e1cda972137955892e649bce4bec4e6ffc7d65 GIT binary patch literal 711 zcmYjPJ#W-N5Zw>^{E<6|DCnR>auXk^5ekYDXc7<+jhoft9ejIPuaC7ONDXcN1RXzz zc3Z0a1tb(^?HtKUJKFc&Xx_}&-C~gwJcqwNs3jxhcL4WKgx~;g{|tj7iW<_=ingp` zl)NU2DgK=(4s^}G@rtYHj1=)T=8}T>yw#19gYInaXKkmz^mUN#p9H}H-hLkgkcui& zF-03%afsG&Fo4-QX^4t`P!+4$6;sI-M?F<3nq@va*}9-*2JOalmjJz=FPF>bLR&p( zX?(gBe57DA6bUA?H}74Bw)osRvW>O?PTR(Xm4sR+(w)N)n4O79-x+CbAm$ShpGgC~ zTTCc9)>hgY+=B_{Z#Qr|zk7((wYtr#SDmi0#k`eYg#p_PtAZm6D-u?=;G;3dpEMYC zibJMiS)x9jW6yN_DphWCXG7GkT5u-(1Qr3-(~3~&Dk zLrNHrZlah`Mt5oSH@zA4(<1VjT1(q>d+OuZ^4R7m-nBHno?;!JzL2gBXhBMvQcA9fVv4^K#evS* z3s0F6wrXb zi<#>~Sr>W8@?|Sqji%!Yx7|1 zYzm3Z8%R1`HrZSyLFvcRw4Aa7NUwWTFAYb=9=i3^Az@ssM8GJc;wN0S(@D%-U(K^> grbp_&mDu(-V%FI{61ebWz2_PJF|q#s19rfF0bRI+rvLx| literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/employees/migrations/__pycache__/0003_alter_employee_address_alter_employee_emp_id_and_more.cpython-310.pyc b/Homework/EmpManagement/employees/migrations/__pycache__/0003_alter_employee_address_alter_employee_emp_id_and_more.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eb3cd3322dc0fd810758fd26cf6df36559394d3b GIT binary patch literal 846 zcmZuvJ&)8d5VezRHVJ!(3L!y_l;*O67NJ8R5Czvzk;d}v%;mB;AJ{n^TOaK;`~v9U zpYR*pA|dTxKteE1HtcG(mOPqy9=-8i6vVys%#tPo9pZ$6(t5>j=j#fS>PwzJV#+NlK4Xw3QtsY^LIB0ma+bWQOgQ#(8tMni3)5;1fm3+oR`{kLqn|On39)grNXuI&W1)RsaL0IVk6PF3Sko= zi2G6@jZqOSrTwnC7XFN><8^co8MRN>iy(zsB{oz*TkUgNu THhMDH`;@!OxLe)v?)v`#lt1NC literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/employees/migrations/__pycache__/0003_delete_role_alter_employee_address_and_more.cpython-310.pyc b/Homework/EmpManagement/employees/migrations/__pycache__/0003_delete_role_alter_employee_address_and_more.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0d6e570e877a615d5b1d15f9c1be01b0a976ec65 GIT binary patch literal 1128 zcmZ`&&2AGh5Vm(W*`Fkk{z|+6VlPbvSA>cv1r9B!<+KvA+<3a()awo2EzmPuBi?}< zufd5M7cTh9DX)Np%6K zK_$s)LUSi^D0xDJBis)}xIjnldpB`~cSPdW6mv=Jm?+Ou&8w_XrD^Ad09g)gXnFJy z?BFcFqXCjoK@vyMlqN2Cqn0f&q3E@RCtBc-0?`(}2qumQCpN?Kk>yh&I-e*;yP`L7 zm!dZ?8X|vlLYLV7HG8dG!>`WxwZCew|Fe5bY}lUDFo{GP<=8ag{#*wXC4_t|iwl6# z+}hsWzRNV^#T#IAn(0D9;vJ%msqqxg!36W5@wpHh%JN|P74^dHd;ur?TvjMHf5#-K zv^tGlL{@HQS8E?LP3t5BDU2szT*W>vbexfGz^?HN+y-aa61ijJV==m6Cm#;UGnhMLi#vh&**$~%t5bG`))5hbm zOvJS2OmvdzvZ{MGq2zNHU(j(TVQL?&X_s7beUU`FFy^|-K~-_b1gu`gn28ue1S0!bFCLoUMU3x8tqIDhW&@T0UTkO!)D=)h87SaEC^E~e|_)*t6 oh&>aE5m#xkC5~&gYEkOo;>e8`V?QRi-{}5;+7@lEeP`4C1F1+Ze*gdg literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/employees/migrations/__pycache__/0004_remove_employee_id_alter_employee_emp_id.cpython-310.pyc b/Homework/EmpManagement/employees/migrations/__pycache__/0004_remove_employee_id_alter_employee_emp_id.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..27ea9ed917c73d32d0597af89cf9aafa93e47155 GIT binary patch literal 711 zcmZ8fO^?$s5cOBON!pb-0pg0ZQZAcHAR(;~+U2mE*aL9N#R{DvayN;C-Ga&$uKgkW zC0{x57eIWB)2+HN(oAMN_B_Am*yH1zk)1rL;GtmbTP$vyqT-y~pHKh>yk#A)cqb~s z*$V~&=Ns$~)ZKy3x(6Uq}jTBb08BS^ObvaM`Hl|fFR(~!N~qY-q5-O$<%q7P^D`TUWt z+Z8&!U)42$L+}4zroJ|y>mGDx9fov&AP55^qsT({b%#NXak4w|=90S8!I`dh8-0zN zka={bZp|kwq|1n$i%N&&oxv8aiaexxoTGKfHKD<}MapMdzhBpFoErjH_Si r&vD;Xp+W}Bx^L_$ydC+CG{)xPzPs!`%?s(%ol?(ugos#o#9jFp0>s9* literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/employees/migrations/__pycache__/__init__.cpython-310.pyc b/Homework/EmpManagement/employees/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..70c9fb9061aa3b2e94646b3f8eaa18673d2433df GIT binary patch literal 146 zcmd1j<>g`kg8vyoDIoeWh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6vMzbHSyM87=0 zD7&~IF*#MgII|>GKQ*@?C%-Z^wOBtlGrcIWBr`v+SU)~KGcU6wK3=b&@)n0pZhlH> PPO2TqxMC(C!NLFl+B_k_ literal 0 HcmV?d00001 diff --git a/Homework/EmpManagement/employees/models.py b/Homework/EmpManagement/employees/models.py new file mode 100644 index 00000000..bc73fd88 --- /dev/null +++ b/Homework/EmpManagement/employees/models.py @@ -0,0 +1,30 @@ +from django.db import models + +DEPARTMENT_CHOICES = ( + ("HR", "HR"), + ("Engineering", "Engineering"), + ("Marketing", "Marketing"), + ("Planning", "Planning"), + ("Sales","Sales"), + ("Finance","Finance"), + ("Operations","Operations"), +) + + + + +class Employee(models.Model): + first_name = models.CharField(max_length=200) + last_name = models.CharField(max_length=200) + address = models.CharField(max_length=200) + emp_id = models.BigAutoField(primary_key=True) + mobile = models.CharField(max_length=10) + dept =models.CharField(max_length=100, choices=DEPARTMENT_CHOICES) + salary = models.IntegerField() + + def __str__(self): + return self.first_name + " " + self.last_name + + + + diff --git a/Homework/EmpManagement/employees/templates/index.html b/Homework/EmpManagement/employees/templates/index.html new file mode 100644 index 00000000..de26a070 --- /dev/null +++ b/Homework/EmpManagement/employees/templates/index.html @@ -0,0 +1,13 @@ + + + + + Sample + + + +

Hello World!

+

Welcome to my first Django project!

+ + + diff --git a/Homework/EmpManagement/employees/tests.py b/Homework/EmpManagement/employees/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/Homework/EmpManagement/employees/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Homework/EmpManagement/employees/urls.py b/Homework/EmpManagement/employees/urls.py new file mode 100644 index 00000000..41c6a7c2 --- /dev/null +++ b/Homework/EmpManagement/employees/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('employee/', views.EmployeeView.as_view()), + path('employee/', views.EmployeeView.as_view()), + path('employee/', views.EmployeeView.as_view()), +] \ No newline at end of file diff --git a/Homework/EmpManagement/employees/views.py b/Homework/EmpManagement/employees/views.py new file mode 100644 index 00000000..43323bcf --- /dev/null +++ b/Homework/EmpManagement/employees/views.py @@ -0,0 +1,78 @@ +from django.views import View +from .models import Employee +from django.http import JsonResponse +from django.views.decorators.csrf import csrf_exempt +from django.utils.decorators import method_decorator +import json + + + + +@method_decorator(csrf_exempt, name='dispatch') +class EmployeeView(View): + + def get(self, request, emp_id=None, dept=None): + employee_model_list = [] + try: + if emp_id: + employee_model_list = Employee.objects.filter(emp_id=emp_id) + elif dept: + employee_model_list = Employee.objects.filter(dept=dept) + except Employee.DoesNotExist: + return JsonResponse({'status': 'Failure', "employees": None}, status=400) + employeess = [] + for employee in employee_model_list: + data = { + "first_name" : employee.first_name, + "last_name": employee.last_name, + "address": employee.address, + "emp_id": employee.emp_id, + "mobile": employee.mobile, + "salary": employee.salary, + "dept": employee.dept + } + employeess.append(data) + return JsonResponse({'status': 'Success', "employees": employeess}, status=200) + + def post(self, request): + if not request.POST.get('first_name') or not request.POST.get('last_name') or not request.POST.get('address') or not request.POST.get('emp_id') or not request.POST.get('mobile') or not request.POST.get('dept') or not request.POST.get('salary'): + return JsonResponse({'status': 'Failure', "message" : "*all the fields are required"}, status=400) + Employee.objects.create( + first_name= request.POST.get('first_name'), + last_name= request.POST.get('last_name'), + address= request.POST.get('address'), + emp_id= request.POST.get('emp_id'), + mobile= request.POST.get('mobile'), + dept= request.POST.get('dept'), + salary= request.POST.get('salary')) + return JsonResponse({'status': 'sucess', "message" : "New employee added by id"}, status=200) + + def delete (self, request, emp_id=None): + try: + val = Employee.objects.get(emp_id=emp_id) + val.delete() + return JsonResponse({'status': 'Success', "message" : "Employee data deleted by id"}, status=200) + except Employee.DoesNotExist: + return JsonResponse({'status': 'Failure', "message" : "Employee not found"}, status=400) + + + + def put(self, request, emp_id=None): + try: + employee = Employee.objects.get(emp_id=emp_id) + except Employee.DoesNotExist: + return JsonResponse({'status': 'Failure', 'message': 'Employee not found'}, status=400) + + try: + request_data = json.loads(request.body) + except json.JSONDecodeError: + return JsonResponse({'status': 'Failure', 'message': 'Invalid JSON payload'}, status=400) + + salary = request_data.get('salary') + if salary is not None: + employee.salary = salary + employee.save() + return JsonResponse({'status': 'Success', 'message': 'Employee salary updated'}, status=200) + else: + return JsonResponse({'status': 'Failure', 'message': 'Please provide a new salary'}, status=400) + diff --git a/Homework/EmpManagement/event_logs.txt b/Homework/EmpManagement/event_logs.txt new file mode 100644 index 00000000..6e3ce568 --- /dev/null +++ b/Homework/EmpManagement/event_logs.txt @@ -0,0 +1,2 @@ +test_get_all_employees_for_dept: Success +test_get_employee_dept: Success diff --git a/Homework/EmpManagement/manage.py b/Homework/EmpManagement/manage.py new file mode 100644 index 00000000..5ac59ac7 --- /dev/null +++ b/Homework/EmpManagement/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'EmpManagement.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/Homework/EmpManagement/unittest_api.py b/Homework/EmpManagement/unittest_api.py new file mode 100644 index 00000000..86057a80 --- /dev/null +++ b/Homework/EmpManagement/unittest_api.py @@ -0,0 +1,53 @@ +import unittest +import requests + + +def print_log(*texts): + with open("event_logs.txt", "a") as file_object: + for text in texts: + file_object.write(str(text) + " ") + file_object.write("\n") + + +class Test(unittest.TestCase): + + def test_get_employee_dept(self): + try: + result = requests.get("http://0.0.0.0:8000/employees/employee/Finance") + self.assertEqual(result.status_code, 200) + self.assertIsNotNone(result.content, None) + print_log("test_get_employee_dept: Success") + except requests.exceptions.ConnectionError: + print('connection error occurred') + print_log("test_get_employee_dept: ConnectionError") + + def test_get_all_employess_for_dept(self): + try: + required = { + 'status': 'Success', + 'employees': [ + { + 'first_name': 'Prajwal', + 'last_name': 'SS', + 'emp_id': 8, + 'address': 'Mangalore', + 'mobile': '9847588659', + 'dept': 'Finance', + 'salary': 120000, + + } + ] + } + + result = requests.get("http://0.0.0.0:8000/employees/employee/8") + self.assertEqual(result.status_code, 200) + result = result.json() + print_log("test_get_all_employees_for_dept: Success") + + except requests.exceptions.ConnectionError: + print('connection error occurred') + print_log("test_get_all_emplyees_for_dept: ConnectionError") + + +if __name__ == '__main__': + unittest.main()