├── .gitignore
├── LICENSE
├── README.md
└── assignments
├── assignment1
├── calculator-cli.py
├── calculator-web.py
└── solutions
│ ├── HelSirius
│ ├── Web_calculator.py
│ └── templates
│ │ └── calculator.html
│ ├── Jlopezjlx
│ └── calc
│ │ ├── maths.py
│ │ └── testcalc.py
│ ├── Prrrince
│ ├── README.md
│ └── calculater.py
│ └── mirpulatov
│ ├── Simple
│ └── test.py
│ ├── Using OOP
│ ├── __init__.py
│ └── test.py
│ └── web-calc
│ ├── calc.py
│ └── test.py
└── assignment2
├── README.md
├── devhub-0.1.0
├── .gitignore
├── LICENSE
├── README.md
├── docs
│ └── README.md
├── requirements.txt
├── src
│ ├── account
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── migrations
│ │ │ ├── 0001_initial.py
│ │ │ └── __init__.py
│ │ ├── models.py
│ │ ├── tests.py
│ │ └── views.py
│ ├── devhub
│ │ ├── __init__.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ └── manage.py
└── tests
│ └── README.md
└── solutions
├── README.md
└── kenanbek
├── .gitignore
├── LICENSE
├── README.md
├── docs
└── README.md
├── requirements.txt
├── src
├── account
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ │ ├── 0001_initial.py
│ │ └── __init__.py
│ ├── models.py
│ ├── templates
│ │ └── account
│ │ │ ├── index.html
│ │ │ ├── login.html
│ │ │ └── register.html
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── devhub
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── manage.py
└── tests
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | *.egg-info/
24 | .installed.cfg
25 | *.egg
26 | MANIFEST
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 | .pytest_cache/
49 |
50 | # Translations
51 | *.mo
52 | *.pot
53 |
54 | # Django stuff:
55 | *.log
56 | local_settings.py
57 | db.sqlite3
58 |
59 | # Flask stuff:
60 | instance/
61 | .webassets-cache
62 |
63 | # Scrapy stuff:
64 | .scrapy
65 |
66 | # Sphinx documentation
67 | docs/_build/
68 |
69 | # PyBuilder
70 | target/
71 |
72 | # Jupyter Notebook
73 | .ipynb_checkpoints
74 |
75 | # pyenv
76 | .python-version
77 |
78 | # celery beat schedule file
79 | celerybeat-schedule
80 |
81 | # SageMath parsed files
82 | *.sage.py
83 |
84 | # Environments
85 | .env
86 | .venv
87 | env/
88 | venv/
89 | ENV/
90 | env.bak/
91 | venv.bak/
92 |
93 | # Spyder project settings
94 | .spyderproject
95 | .spyproject
96 |
97 | # Rope project settings
98 | .ropeproject
99 |
100 | # mkdocs documentation
101 | /site
102 |
103 | # mypy
104 | .mypy_cache/
105 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Python Mentorship 2.0
2 |
3 | Source for Python Mentorship program.
4 |
5 | For all details of the Python Mentorship 2.0 program please visit:
6 | http://codervlogger.com/python-mentorship/
7 |
8 | # Introduction
9 |
10 | Python Mentorship 2.0 is a mentorship program for Python beginners and it’s free. During the mentorship process I will be guiding Python newbies through Python learning process by following steps:
11 |
12 | - Explaining important Python programming topics and referencing sources where you can get advanced information
13 | - Giving assignments and showing examples
14 | - Checking completed assignments and doing a code review
15 |
16 | Introduction videos:
17 |
18 | 1. [Introduction and Basics](https://www.youtube.com/watch?v=n10Io1LKcAk&list=PLxa49UnOmIzqHkmBagunmLgZx8_DsXCIN&index=2)
19 | 2. [What do you need to start?](https://www.youtube.com/watch?v=Qx8P841V9u4&list=PLxa49UnOmIzqHkmBagunmLgZx8_DsXCIN&index=2)
20 | 3. [How to submit a question?](https://www.youtube.com/watch?v=UwpZayjeUjE&list=PLxa49UnOmIzqHkmBagunmLgZx8_DsXCIN&index=4)
21 |
22 | # Assignments
23 |
24 | Currently, we have following assignments:
25 |
26 | 1. Assignment1 - web and commandline calculator application
27 | 2. Assignment2 - setup Django 2 project with back-end, front-end, Docker/Docker Compose and custom user model
28 |
29 | Now, more detailed:
30 |
31 | ## Assignment1
32 |
33 | [](https://www.youtube.com/watch?v=UwpZayjeUjE)
34 |
35 | More information & Discussions:
36 | https://github.com/CoderVlogger/python-mentorship/issues/2
37 |
38 | Topics:
39 | - cmd calculator app
40 | - flask calculator app
41 |
42 | Solved by:
43 | @mirpulatov, @Jlopezjlx, @Prrrince, @HelSirius
44 |
45 | #### Solutions
46 | https://github.com/CoderVlogger/python-mentorship/tree/master/assignments/assignment1
47 |
48 | #### Code review for the Assignment #1
49 | [](https://www.youtube.com/watch?v=dVJJf07LcU8)
50 |
51 | ## Assignment2
52 |
53 | [](https://www.youtube.com/watch?v=llGucucq9JE)
54 |
55 | More information & Discussions:
56 | https://github.com/CoderVlogger/python-mentorship/issues/7
57 |
58 | Topics:
59 | - setup a Django project
60 | - create a custom user model
61 | - use Docer and Docker Compose
62 |
63 | #### Tutorial videos
64 |
65 | 1. [Django Web Framework: How to Setup Django 2.1 and Python 3 Example Project Structure with GitHub](https://youtu.be/d4QoVKEkPjI)
66 | 2. [Introduction & Custom User Model](https://youtu.be/cg0KNJZqInY)
67 | 3. [Setup URLs, templates and HTML views for Account application](https://youtu.be/yNlRzTfZi8Q)
68 |
69 | #### Solutions
70 |
71 | https://github.com/CoderVlogger/python-mentorship/tree/master/assignments/assignment2
72 |
73 |
74 |
--------------------------------------------------------------------------------
/assignments/assignment1/calculator-cli.py:
--------------------------------------------------------------------------------
1 |
2 | def add(x, y):
3 | return x + y
4 |
5 | print("Choice operation: ")
6 | print("1. Add")
7 | print("2. Subtract")
8 | print("3. Multiply")
9 | print("4. Divide")
10 |
11 | operation = input("Operation: ")
12 |
13 | x = int(input("Enter X: "))
14 | y = int(input("Enter Y: "))
15 |
16 | if operation == 1:
17 | r = add(x, y)
18 | elif operation == 2:
19 | r = x - y
20 |
21 | elif operation == 3:
22 | r = x * y
23 |
24 | elif operation == 4:
25 | r = x / y
26 |
27 | print("Result: ", r)
28 |
--------------------------------------------------------------------------------
/assignments/assignment1/calculator-web.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment1/calculator-web.py
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/HelSirius/Web_calculator.py:
--------------------------------------------------------------------------------
1 | from flask import Flask,render_template,request
2 | from flask_wtf import FlaskForm
3 | from wtforms import SubmitField, IntegerField
4 | import os
5 |
6 |
7 | app = Flask(__name__)
8 | SECRET_KEY = os.urandom(32)
9 | app.config['SECRET_KEY'] = SECRET_KEY
10 |
11 |
12 |
13 | class CalculateForm(FlaskForm):
14 |
15 | First_Num = IntegerField('First Number')
16 | Second_Num = IntegerField('Second Number')
17 | plus = SubmitField('Addition')
18 | minus = SubmitField('Substraction')
19 | multiply = SubmitField('Multiplication')
20 | divide = SubmitField('Division')
21 |
22 | @app.route('/',methods = ['GET','POST'])
23 | def index():
24 | form =CalculateForm()
25 |
26 | if form.validate_on_submit():
27 | First_Num = request.form.get ('First_Num', type=int)
28 | Second_Num = request.form.get ('Second_Num', type=int)
29 |
30 | if form.plus.data:
31 | add = First_Num + Second_Num
32 | elif form.minus.data:
33 | substract = First_Num - Second_Num
34 | elif form.multiply.data:
35 | mult = First_Num * Second_Num
36 | elif form.divide.data:
37 | divide = First_Num / Second_Num
38 | return render_template('calculator.html',**locals())
39 | return render_template('calculator.html',form=form)
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/HelSirius/templates/calculator.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
65 |
72 |
73 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/Jlopezjlx/calc/maths.py:
--------------------------------------------------------------------------------
1 | def sumar(a,b):
2 | return a + b
3 |
4 | def restar(a,b):
5 | return a - b
6 |
7 | def multiplicacion(a,b):
8 | return a * b
9 |
10 | def division(a,b):
11 | return a / b
12 |
13 | def restante(a,b):
14 | return a % b
15 |
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/Jlopezjlx/calc/testcalc.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import calc
3 |
4 | class testing_calc(unittest.TestCase):
5 |
6 |
7 | def test_sumar(self):
8 | result = calc.sumar(2,3)
9 | self.assertEqual(5,result)
10 |
11 |
12 | def test_restar(self):
13 | result = calc.restar(2,3)
14 | expected = 2 - 3
15 | self.assertEqual(expected,result)
16 |
17 |
18 | def test_multiplcacion(self):
19 | result = calc.multiplicacion(2,3)
20 | expected = 2 * 3
21 | self.assertEqual(expected, result)
22 |
23 |
24 | def test_division(self):
25 | result = calc.division(2,3)
26 | expected = 2 / 3
27 | self.assertEqual(expected, result)
28 |
29 |
30 | def test_restante(self):
31 | result = calc.restante(2,3)
32 | expected = 2 % 3
33 | self.assertEqual(expected, result)
34 |
35 |
36 | if __name__ == '__main__':
37 | unittest.main()
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/Prrrince/README.md:
--------------------------------------------------------------------------------
1 | # PyCalc
2 | Simple Calculater Made in Python
3 |
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/Prrrince/calculater.py:
--------------------------------------------------------------------------------
1 | operations = ['Addition', 'Substraction', 'Multipication', 'Division', 'Modular Division', 'Exit']
2 |
3 | while True:
4 | print("Choose Operation : ")
5 |
6 | for index, operation in enumerate(operations, start=1):
7 | print(f'( {index} ) {operation} ')
8 |
9 | try:
10 | operator = int(input("Enter Number of Operation:"))
11 | if operator == 6:
12 | print("Tata Tata !")
13 | break
14 |
15 | first_number = int(input("Enter First No : "))
16 | second_number = int(input("Enter Second No : "))
17 |
18 | except ValueError:
19 | print("X-X-X Enter Integer Values Only X-X-X")
20 | continue
21 |
22 | if operator == 1:
23 | result = first_number + second_number
24 |
25 | elif operator == 2:
26 | result = first_number - second_number
27 |
28 | elif operator == 3:
29 | result = first_number * second_number
30 |
31 | elif operator == 4:
32 | result = first_number / second_number
33 |
34 | elif operator == 5:
35 | result = first_number % second_number
36 |
37 | else:
38 | print("X-X-X Invalid Operation Number X-X-X")
39 | continue
40 |
41 | print(f'{operations[operator-1]} is {result}')
42 |
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/mirpulatov/Simple/test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import app
3 |
4 | class SimpleTest(unittest.TestCase):
5 |
6 | def testCalculation(self):
7 | self.assertEqual(app.plus(3, 2), 5)
8 | self.assertEqual(app.minus(3, 2), 1)
9 | self.assertEqual(app.multiply(3, 2), 6)
10 | self.assertEqual(app.div(4, 2), 2)
11 |
12 | if __name__ == "__main__":
13 | unittest.main()
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/mirpulatov/Using OOP/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment1/solutions/mirpulatov/Using OOP/__init__.py
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/mirpulatov/Using OOP/test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from calc import Calculator
3 |
4 | calc = Calculator(6, 2)
5 |
6 | class SimpleTest(unittest.TestCase):
7 |
8 | def testCalculation(self):
9 | self.assertEqual(calc.plus(), 8)
10 | self.assertEqual(calc.minus(), 4)
11 | self.assertEqual(calc.multiply(), 12)
12 | self.assertEqual(calc.div(), 3)
13 |
14 | if __name__ == "__main__":
15 | unittest.main()
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/mirpulatov/web-calc/calc.py:
--------------------------------------------------------------------------------
1 | class Calculator:
2 |
3 | def __init__(self, x, y):
4 | self.x = x
5 | self.y = y
6 |
7 | def plus(self):
8 | return self.x + self.y
9 |
10 | def minus(self):
11 | return self.x - self.y
12 |
13 | def multiply(self):
14 | return self.x * self.y
15 |
16 | def div(self):
17 | if self.y == 0:
18 | print('Division by zero!')
19 | else:
20 | return self.x / self.y
21 |
--------------------------------------------------------------------------------
/assignments/assignment1/solutions/mirpulatov/web-calc/test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from calc import Calculator
3 |
4 | calc = Calculator(6, 2)
5 |
6 | class SimpleTest(unittest.TestCase):
7 |
8 | def testCalculation(self):
9 | self.assertEqual(calc.plus(), 8)
10 | self.assertEqual(calc.minus(), 4)
11 | self.assertEqual(calc.multiply(), 12)
12 | self.assertEqual(calc.div(), 3)
13 |
14 | if __name__ == "__main__":
15 | unittest.main()
--------------------------------------------------------------------------------
/assignments/assignment2/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment2/README.md
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/.gitignore:
--------------------------------------------------------------------------------
1 | # IDE
2 | .vscode/
3 |
4 | # Byte-compiled / optimized / DLL files
5 | __pycache__/
6 | *.py[cod]
7 | *$py.class
8 |
9 | # C extensions
10 | *.so
11 |
12 | # Distribution / packaging
13 | .Python
14 | build/
15 | develop-eggs/
16 | dist/
17 | downloads/
18 | eggs/
19 | .eggs/
20 | lib/
21 | lib64/
22 | parts/
23 | sdist/
24 | var/
25 | wheels/
26 | *.egg-info/
27 | .installed.cfg
28 | *.egg
29 | MANIFEST
30 |
31 | # PyInstaller
32 | # Usually these files are written by a python script from a template
33 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
34 | *.manifest
35 | *.spec
36 |
37 | # Installer logs
38 | pip-log.txt
39 | pip-delete-this-directory.txt
40 |
41 | # Unit test / coverage reports
42 | htmlcov/
43 | .tox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 |
62 | # Flask stuff:
63 | instance/
64 | .webassets-cache
65 |
66 | # Scrapy stuff:
67 | .scrapy
68 |
69 | # Sphinx documentation
70 | docs/_build/
71 |
72 | # PyBuilder
73 | target/
74 |
75 | # Jupyter Notebook
76 | .ipynb_checkpoints
77 |
78 | # pyenv
79 | .python-version
80 |
81 | # celery beat schedule file
82 | celerybeat-schedule
83 |
84 | # SageMath parsed files
85 | *.sage.py
86 |
87 | # Environments
88 | .env
89 | .venv
90 | env/
91 | venv/
92 | ENV/
93 | env.bak/
94 | venv.bak/
95 |
96 | # Spyder project settings
97 | .spyderproject
98 | .spyproject
99 |
100 | # Rope project settings
101 | .ropeproject
102 |
103 | # mkdocs documentation
104 | /site
105 |
106 | # mypy
107 | .mypy_cache/
108 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/README.md:
--------------------------------------------------------------------------------
1 | # DevHub
2 |
3 | Hub for DEVelopment related stuff: news, articles, source codes, ideas, etc.
4 |
5 | ## Related [YouTube](http://youtube.com/CoderVlogger "CoderVlogger's YouTube channel") videos
6 |
7 | 1. [Introduction & Custom User Model](https://youtu.be/cg0KNJZqInY)
8 |
9 | # Setup
10 |
11 | ## Using `virtualenv`
12 |
13 | 1. Make sure you have [Python 3] and [virtualenv] installed
14 | 2. Clone this repository: `git clone https://github.com/CoderVlogger/devhub.git`
15 | 3. Move into the project folder: `cd devhub`
16 | 4. Create a new virtualenv: `virtualenv venv -p python3`
17 | 5. Activate the virtualenv: `source ./venv/bin/activate`
18 | 6. Install dependencies: `pip install -r requirements.txt`
19 |
20 |
21 | # Project Structure
22 |
23 | ## Repository structure
24 |
25 | 1. `src` - source code
26 | 2. `docs` - auto generated Sphinx documentation (to be added)
27 | 3. `tests` - high level tests (e2e, load, etc. - to be added)
28 |
29 | ## Django applications
30 |
31 | 1. Account
32 | 1. User side register, login and logout
33 | 2. Profile and account settings
34 | 2. Board (to be added)
35 | 1. Share public posts
36 | 2. Post rating system
37 | 3. Post comments
38 |
39 | [Python 3]: https://www.python.org/downloads/
40 | [virtualenv]: https://virtualenv.pypa.io/en/stable/
41 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/docs/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment2/devhub-0.1.0/docs/README.md
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/requirements.txt:
--------------------------------------------------------------------------------
1 | astroid==2.2.5
2 | Django==2.1.7
3 | isort==4.3.16
4 | lazy-object-proxy==1.3.1
5 | mccabe==0.6.1
6 | pylint==2.3.1
7 | pytz==2018.9
8 | six==1.12.0
9 | typed-ast==1.3.1
10 | wrapt==1.11.1
11 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/account/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment2/devhub-0.1.0/src/account/__init__.py
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/account/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.contrib.auth.admin import UserAdmin
3 | from account import models as account_models
4 |
5 |
6 | admin.site.register(account_models.Account, UserAdmin)
7 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/account/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class AccountConfig(AppConfig):
5 | name = 'account'
6 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/account/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.1.7 on 2019-04-19 12:09
2 |
3 | import django.contrib.auth.models
4 | import django.contrib.auth.validators
5 | from django.db import migrations, models
6 | import django.utils.timezone
7 |
8 |
9 | class Migration(migrations.Migration):
10 |
11 | initial = True
12 |
13 | dependencies = [
14 | ('auth', '0009_alter_user_last_name_max_length'),
15 | ]
16 |
17 | operations = [
18 | migrations.CreateModel(
19 | name='Account',
20 | fields=[
21 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
22 | ('password', models.CharField(max_length=128, verbose_name='password')),
23 | ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
24 | ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
25 | ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
26 | ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
27 | ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
28 | ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
29 | ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
30 | ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
31 | ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
32 | ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
33 | ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
34 | ],
35 | options={
36 | 'verbose_name': 'user',
37 | 'verbose_name_plural': 'users',
38 | 'abstract': False,
39 | },
40 | managers=[
41 | ('objects', django.contrib.auth.models.UserManager()),
42 | ],
43 | ),
44 | ]
45 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/account/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment2/devhub-0.1.0/src/account/migrations/__init__.py
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/account/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth.models import AbstractUser
3 |
4 |
5 | class Account(AbstractUser):
6 | """
7 | With this class we are customazing Django's User model.
8 | More information here:
9 | https://docs.djangoproject.com/en/dev/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project
10 | """
11 | REQUIRED_FIELDS = ['email']
12 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/account/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/account/views.py:
--------------------------------------------------------------------------------
1 | from django.shortcuts import render
2 |
3 | # Create your views here.
4 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/devhub/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment2/devhub-0.1.0/src/devhub/__init__.py
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/devhub/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for devhub project.
3 |
4 | Generated by 'django-admin startproject' using Django 2.1.7.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.1/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/2.1/ref/settings/
11 | """
12 |
13 | import os
14 |
15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = '%sl=sr@84$rrenr8=!p@7733st0ggv4&6(#ipbq()1yvbd2rjv'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = []
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'account.apps.AccountConfig',
35 | 'django.contrib.admin',
36 | 'django.contrib.auth',
37 | 'django.contrib.contenttypes',
38 | 'django.contrib.sessions',
39 | 'django.contrib.messages',
40 | 'django.contrib.staticfiles',
41 | ]
42 |
43 | MIDDLEWARE = [
44 | 'django.middleware.security.SecurityMiddleware',
45 | 'django.contrib.sessions.middleware.SessionMiddleware',
46 | 'django.middleware.common.CommonMiddleware',
47 | 'django.middleware.csrf.CsrfViewMiddleware',
48 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
49 | 'django.contrib.messages.middleware.MessageMiddleware',
50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
51 | ]
52 |
53 | ROOT_URLCONF = 'devhub.urls'
54 |
55 | TEMPLATES = [
56 | {
57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
58 | 'DIRS': [],
59 | 'APP_DIRS': True,
60 | 'OPTIONS': {
61 | 'context_processors': [
62 | 'django.template.context_processors.debug',
63 | 'django.template.context_processors.request',
64 | 'django.contrib.auth.context_processors.auth',
65 | 'django.contrib.messages.context_processors.messages',
66 | ],
67 | },
68 | },
69 | ]
70 |
71 | WSGI_APPLICATION = 'devhub.wsgi.application'
72 |
73 |
74 | # Database
75 | # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
76 |
77 | DATABASES = {
78 | 'default': {
79 | 'ENGINE': 'django.db.backends.sqlite3',
80 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
81 | }
82 | }
83 |
84 |
85 | # Password validation
86 | # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
87 |
88 | AUTH_PASSWORD_VALIDATORS = [
89 | {
90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
91 | },
92 | {
93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
94 | },
95 | {
96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
97 | },
98 | {
99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
100 | },
101 | ]
102 |
103 |
104 | # Internationalization
105 | # https://docs.djangoproject.com/en/2.1/topics/i18n/
106 |
107 | LANGUAGE_CODE = 'en-us'
108 |
109 | TIME_ZONE = 'UTC'
110 |
111 | USE_I18N = True
112 |
113 | USE_L10N = True
114 |
115 | USE_TZ = True
116 |
117 |
118 | # Static files (CSS, JavaScript, Images)
119 | # https://docs.djangoproject.com/en/2.1/howto/static-files/
120 |
121 | STATIC_URL = '/static/'
122 |
123 | # Custom User model
124 | # https://docs.djangoproject.com/en/dev/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project
125 | AUTH_USER_MODEL = 'account.Account'
126 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/devhub/urls.py:
--------------------------------------------------------------------------------
1 | """devhub URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.1/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path
18 |
19 | urlpatterns = [
20 | path('admin/', admin.site.urls),
21 | ]
22 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/devhub/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for devhub project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'devhub.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/src/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == '__main__':
6 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'devhub.settings')
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/assignments/assignment2/devhub-0.1.0/tests/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment2/devhub-0.1.0/tests/README.md
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/README.md:
--------------------------------------------------------------------------------
1 | Please put your changes into this folder with your name and source code. Example:
2 |
3 | ```
4 | /
5 | ```
6 |
7 | For source code please copy/paste DevHub version v0.1.0 (it is also in direcotry).
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/.gitignore:
--------------------------------------------------------------------------------
1 | # IDE
2 | .vscode/
3 |
4 | # Byte-compiled / optimized / DLL files
5 | __pycache__/
6 | *.py[cod]
7 | *$py.class
8 |
9 | # C extensions
10 | *.so
11 |
12 | # Distribution / packaging
13 | .Python
14 | build/
15 | develop-eggs/
16 | dist/
17 | downloads/
18 | eggs/
19 | .eggs/
20 | lib/
21 | lib64/
22 | parts/
23 | sdist/
24 | var/
25 | wheels/
26 | *.egg-info/
27 | .installed.cfg
28 | *.egg
29 | MANIFEST
30 |
31 | # PyInstaller
32 | # Usually these files are written by a python script from a template
33 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
34 | *.manifest
35 | *.spec
36 |
37 | # Installer logs
38 | pip-log.txt
39 | pip-delete-this-directory.txt
40 |
41 | # Unit test / coverage reports
42 | htmlcov/
43 | .tox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | .hypothesis/
51 | .pytest_cache/
52 |
53 | # Translations
54 | *.mo
55 | *.pot
56 |
57 | # Django stuff:
58 | *.log
59 | local_settings.py
60 | db.sqlite3
61 |
62 | # Flask stuff:
63 | instance/
64 | .webassets-cache
65 |
66 | # Scrapy stuff:
67 | .scrapy
68 |
69 | # Sphinx documentation
70 | docs/_build/
71 |
72 | # PyBuilder
73 | target/
74 |
75 | # Jupyter Notebook
76 | .ipynb_checkpoints
77 |
78 | # pyenv
79 | .python-version
80 |
81 | # celery beat schedule file
82 | celerybeat-schedule
83 |
84 | # SageMath parsed files
85 | *.sage.py
86 |
87 | # Environments
88 | .env
89 | .venv
90 | env/
91 | venv/
92 | ENV/
93 | env.bak/
94 | venv.bak/
95 |
96 | # Spyder project settings
97 | .spyderproject
98 | .spyproject
99 |
100 | # Rope project settings
101 | .ropeproject
102 |
103 | # mkdocs documentation
104 | /site
105 |
106 | # mypy
107 | .mypy_cache/
108 |
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/README.md:
--------------------------------------------------------------------------------
1 | # DevHub
2 |
3 | Hub for DEVelopment related stuff: news, articles, source codes, ideas, etc.
4 |
5 | ## Related [YouTube](http://youtube.com/CoderVlogger "CoderVlogger's YouTube channel") videos
6 |
7 | 1. [Introduction & Custom User Model](https://youtu.be/cg0KNJZqInY)
8 |
9 | # Setup
10 |
11 | ## Using `virtualenv`
12 |
13 | 1. Make sure you have [Python 3] and [virtualenv] installed
14 | 2. Clone this repository: `git clone https://github.com/CoderVlogger/devhub.git`
15 | 3. Move into the project folder: `cd devhub`
16 | 4. Create a new virtualenv: `virtualenv venv -p python3`
17 | 5. Activate the virtualenv: `source ./venv/bin/activate`
18 | 6. Install dependencies: `pip install -r requirements.txt`
19 |
20 |
21 | # Project Structure
22 |
23 | ## Repository structure
24 |
25 | 1. `src` - source code
26 | 2. `docs` - auto generated Sphinx documentation (to be added)
27 | 3. `tests` - high level tests (e2e, load, etc. - to be added)
28 |
29 | ## Django applications
30 |
31 | 1. Account
32 | 1. User side register, login and logout
33 | 2. Profile and account settings
34 | 2. Board (to be added)
35 | 1. Share public posts
36 | 2. Post rating system
37 | 3. Post comments
38 |
39 | [Python 3]: https://www.python.org/downloads/
40 | [virtualenv]: https://virtualenv.pypa.io/en/stable/
41 |
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/docs/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment2/solutions/kenanbek/docs/README.md
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/requirements.txt:
--------------------------------------------------------------------------------
1 | astroid==2.2.5
2 | Django==2.1.7
3 | isort==4.3.16
4 | lazy-object-proxy==1.3.1
5 | mccabe==0.6.1
6 | pylint==2.3.1
7 | pytz==2018.9
8 | six==1.12.0
9 | typed-ast==1.3.1
10 | wrapt==1.11.1
11 |
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/src/account/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment2/solutions/kenanbek/src/account/__init__.py
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/src/account/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.contrib.auth.admin import UserAdmin
3 | from account import models as account_models
4 |
5 |
6 | admin.site.register(account_models.Account, UserAdmin)
7 |
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/src/account/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class AccountConfig(AppConfig):
5 | name = 'account'
6 |
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/src/account/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.1.7 on 2019-04-13 20:00
2 |
3 | import django.contrib.auth.models
4 | import django.contrib.auth.validators
5 | from django.db import migrations, models
6 | import django.utils.timezone
7 |
8 |
9 | class Migration(migrations.Migration):
10 |
11 | initial = True
12 |
13 | dependencies = [
14 | ('auth', '0009_alter_user_last_name_max_length'),
15 | ]
16 |
17 | operations = [
18 | migrations.CreateModel(
19 | name='Account',
20 | fields=[
21 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
22 | ('password', models.CharField(max_length=128, verbose_name='password')),
23 | ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
24 | ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
25 | ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
26 | ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
27 | ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
28 | ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
29 | ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
30 | ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
31 | ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
32 | ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
33 | ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
34 | ],
35 | options={
36 | 'verbose_name': 'user',
37 | 'verbose_name_plural': 'users',
38 | 'abstract': False,
39 | },
40 | managers=[
41 | ('objects', django.contrib.auth.models.UserManager()),
42 | ],
43 | ),
44 | ]
45 |
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/src/account/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CoderVlogger/python-mentorship/1be5a64d6a5eeef92ff29d9d63c971410d1a419b/assignments/assignment2/solutions/kenanbek/src/account/migrations/__init__.py
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/src/account/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib.auth.models import AbstractUser
3 |
4 |
5 | class Account(AbstractUser):
6 | """
7 | With this class we are customazing Django's User model.
8 | More information here:
9 | https://docs.djangoproject.com/en/dev/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project
10 | """
11 | REQUIRED_FIELDS = ['email']
12 |
--------------------------------------------------------------------------------
/assignments/assignment2/solutions/kenanbek/src/account/templates/account/index.html:
--------------------------------------------------------------------------------
1 |