Merge remote-tracking branch 'origin/BES-16'
This commit is contained in:
commit
eff2492c4c
@ -1,86 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="b23c009e-2f8a-48f7-8b29-023f93596932" name="Default Changelist" comment="" />
|
||||
<list default="true" id="b23c009e-2f8a-48f7-8b29-023f93596932" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/bestnotes/dbAPI.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/bestnotes/models.py" beforeDir="false" afterPath="$PROJECT_DIR$/bestnotes/models.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/bestnotes/tests.py" beforeDir="false" afterPath="$PROJECT_DIR$/bestnotes/tests.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/db.sqlite3" beforeDir="false" afterPath="$PROJECT_DIR$/db.sqlite3" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/BestNotesProject/urls.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="357">
|
||||
<caret line="22" selection-start-line="22" selection-end-line="22" />
|
||||
<folding>
|
||||
<element signature="e#640#672#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/bestnotes/urls.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="51">
|
||||
<caret line="5" column="37" selection-start-line="5" selection-start-column="37" selection-end-line="5" selection-end-column="37" />
|
||||
<folding>
|
||||
<element signature="e#0#28#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/bestnotes/views.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="51">
|
||||
<caret line="7" column="55" selection-start-line="7" selection-start-column="55" selection-end-line="7" selection-end-column="55" />
|
||||
<folding>
|
||||
<element signature="e#0#35#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/bestnotes/models.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="156">
|
||||
<caret line="15" column="86" selection-start-line="15" selection-start-column="86" selection-end-line="15" selection-end-column="86" />
|
||||
<folding>
|
||||
<element signature="e#0#28#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/bestnotes/admin.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="102">
|
||||
<caret line="6" column="34" selection-start-line="6" selection-start-column="34" selection-end-line="6" selection-end-column="34" />
|
||||
<folding>
|
||||
<element signature="e#0#32#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/BestNotesProject/settings.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="306">
|
||||
<caret line="33" column="37" selection-start-line="33" selection-start-column="37" selection-end-line="33" selection-end-column="37" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
@ -93,61 +26,13 @@
|
||||
<find>bestnotes.apps.BestnotesConfigdjango</find>
|
||||
</findStrings>
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/BestNotesProject/urls.py" />
|
||||
<option value="$PROJECT_DIR$/bestnotes/urls.py" />
|
||||
<option value="$PROJECT_DIR$/bestnotes/views.py" />
|
||||
<option value="$PROJECT_DIR$/BestNotesProject/settings.py" />
|
||||
<option value="$PROJECT_DIR$/bestnotes/admin.py" />
|
||||
<option value="$PROJECT_DIR$/bestnotes/models.py" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="377" />
|
||||
<option name="y" value="92" />
|
||||
<option name="width" value="1324" />
|
||||
<option name="height" value="1000" />
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectId" id="1U5Jq3TEUnuX8tmyYK4OsXqAEBc" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectView">
|
||||
<navigator proportions="" version="1">
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="BestNotesProject" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="BestNotesProject" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="BestNotesProject" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="BestNotesProject" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="bestnotes" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="BestNotesProject" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="BestNotesProject" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="bestnotes" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="migrations" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="BestNotesProject" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="BestNotesProject" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="BestNotesProject" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="settings.editor.selected.configurable" value="preferences.general" />
|
||||
</component>
|
||||
@ -163,6 +48,27 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="Unittests in bestnotesunittests.py" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
|
||||
<module name="BestNotesProject" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="_new_additionalArguments" value="""" />
|
||||
<option name="_new_target" value=""$PROJECT_DIR$/bestnotes/bestnotesunittests.py"" />
|
||||
<option name="_new_targetType" value=""PATH"" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python tests.Unittests in bestnotesunittests.py" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
@ -176,109 +82,17 @@
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="302" y="74" width="1059" height="800" extended-state="0" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.20136853" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info id="Favorites" order="2" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info anchor="bottom" id="Run" order="2" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="bottom" id="Version Control" order="7" />
|
||||
<window_info active="true" anchor="bottom" id="Terminal" order="8" visible="true" weight="0.32884902" />
|
||||
<window_info anchor="bottom" id="Event Log" order="9" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Python Console" order="10" weight="0.32884902" />
|
||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/BestNotesProject/urls.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="357">
|
||||
<caret line="22" selection-start-line="22" selection-end-line="22" />
|
||||
<folding>
|
||||
<element signature="e#640#672#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/bestnotes/urls.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="51">
|
||||
<caret line="5" column="37" selection-start-line="5" selection-start-column="37" selection-end-line="5" selection-end-column="37" />
|
||||
<folding>
|
||||
<element signature="e#0#28#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/bestnotes/views.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="51">
|
||||
<caret line="7" column="55" selection-start-line="7" selection-start-column="55" selection-end-line="7" selection-end-column="55" />
|
||||
<folding>
|
||||
<element signature="e#0#35#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://D:/Programming/Python/Python_3.8/Lib/site-packages/django/apps/config.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="140">
|
||||
<caret line="115" selection-start-line="115" selection-end-line="115" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://D:/Programming/Python/Python_3.8/Lib/importlib/__init__.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="140">
|
||||
<caret line="126" selection-start-line="126" selection-end-line="126" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/bestnotes/apps.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="85">
|
||||
<caret line="5" lean-forward="true" selection-start-line="5" selection-end-line="5" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/BestNotesProject/settings.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="306">
|
||||
<caret line="33" column="37" selection-start-line="33" selection-start-column="37" selection-end-line="33" selection-end-column="37" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/bestnotes/admin.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="102">
|
||||
<caret line="6" column="34" selection-start-line="6" selection-start-column="34" selection-end-line="6" selection-end-column="34" />
|
||||
<folding>
|
||||
<element signature="e#0#32#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/bn_migrate_log.txt">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/bestnotes/models.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="156">
|
||||
<caret line="15" column="86" selection-start-line="15" selection-start-column="86" selection-end-line="15" selection-end-column="86" />
|
||||
<folding>
|
||||
<element signature="e#0#28#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State>
|
||||
<option name="COLUMN_ORDER" />
|
||||
</State>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
BIN
bestnotes/__pycache__/dbAPI.cpython-38.pyc
Normal file
BIN
bestnotes/__pycache__/dbAPI.cpython-38.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
bestnotes/__pycache__/tests.cpython-38.pyc
Normal file
BIN
bestnotes/__pycache__/tests.cpython-38.pyc
Normal file
Binary file not shown.
44
bestnotes/dbAPI.py
Normal file
44
bestnotes/dbAPI.py
Normal file
@ -0,0 +1,44 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
def add_student(username, email=None, password=None, **kwargs):
|
||||
new_student = User.objects.create_user(username, email, password)
|
||||
|
||||
if kwargs.get('first_name', 0) != 0 :
|
||||
new_student.first_name = kwargs.get('first_name', 0)
|
||||
if kwargs.get('last_name', 0) != 0:
|
||||
new_student.last_name = kwargs.get('last_name', 0)
|
||||
if kwargs.get('bio', 0) != 0:
|
||||
new_student.studentprofile.bio = kwargs.get('bio', 0)
|
||||
if kwargs.get('birth_date', 0) != 0:
|
||||
new_student.studentprofile.birth_date = kwargs.get('birth_date', 0)
|
||||
if kwargs.get('location', 0) != 0:
|
||||
new_student.studentprofile.location = kwargs.get('location', 0)
|
||||
|
||||
new_student.save()
|
||||
|
||||
def delete_student(id):
|
||||
s = User.objects.get(id=id)
|
||||
s.delete()
|
||||
|
||||
"""
|
||||
id - id of object to be updated
|
||||
kwargs - new values for object
|
||||
"""
|
||||
def update_student(id, **kwargs):
|
||||
student = User.objects.get(id=id)
|
||||
if kwargs.get('email', 0) != 0 :
|
||||
student.email = kwargs.get('email', 0)
|
||||
if kwargs.get('first_name', 0) != 0 :
|
||||
student.first_name = kwargs.get('first_name', 0)
|
||||
if kwargs.get('last_name', 0) != 0:
|
||||
student.last_name = kwargs.get('last_name', 0)
|
||||
if kwargs.get('bio', 0) != 0:
|
||||
student.studentprofile.bio = kwargs.get('bio', 0)
|
||||
if kwargs.get('birth_date', 0) != 0:
|
||||
student.studentprofile.birth_date = kwargs.get('birth_date', 0)
|
||||
if kwargs.get('location', 0) != 0:
|
||||
student.studentprofile.location = kwargs.get('location', 0)
|
||||
|
||||
student.save()
|
@ -18,6 +18,7 @@ class StudentProfile(models.Model):
|
||||
to add as foreign key, when coresponding table is added:
|
||||
CourseId
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,3 +1,49 @@
|
||||
from django.test import TestCase
|
||||
from .dbAPI import add_student, update_student
|
||||
from django.contrib.auth.models import User
|
||||
import datetime
|
||||
|
||||
# Create your tests here.
|
||||
|
||||
class TestStudentProfiledbAPI(TestCase):
|
||||
def test_add_student(self):
|
||||
testuser = "testUser"
|
||||
testemail = "testuser@example.com"
|
||||
testPassword = 'testtest02'
|
||||
testkwargs = {
|
||||
"first_name" : "testname",
|
||||
"last_name" : "testsurname",
|
||||
"bio" : "testbio",
|
||||
"birth_date" : datetime.date(2019, 11, 25),
|
||||
"location" : "testlocation"
|
||||
}
|
||||
add_student(testuser, testemail, testPassword, **testkwargs)
|
||||
test = User.objects.get(username=testuser)
|
||||
self.assertEqual(test.username, testuser)
|
||||
self.assertEqual(test.email, testemail)
|
||||
self.assertNotEqual(test.password, testPassword)
|
||||
self.assertEqual(test.first_name, "testname")
|
||||
self.assertEqual(test.last_name, "testsurname")
|
||||
self.assertEqual(test.studentprofile.bio, "testbio")
|
||||
self.assertEqual(test.studentprofile.birth_date, datetime.date(2019, 11, 25))
|
||||
self.assertEqual(test.studentprofile.location, "testlocation")
|
||||
|
||||
def test_update_student(self):
|
||||
testuser = "testUser2"
|
||||
testemail = "testuser@example.com"
|
||||
testPassword = 'testtest02'
|
||||
testkwargs = {
|
||||
"first_name": "testname",
|
||||
"last_name": "testsurname",
|
||||
"bio": "testbio",
|
||||
"birth_date": datetime.date(2019, 11, 25),
|
||||
"location": "testlocation"
|
||||
}
|
||||
add_student(testuser, testemail, testPassword, **testkwargs)
|
||||
test = User.objects.get(username=testuser)
|
||||
test_date = datetime.date(1999, 9, 9)
|
||||
update_student(test.id, **{"first_name": "Janek", "birth_date": test_date})
|
||||
test = User.objects.get(username=testuser)
|
||||
self.assertEqual(test.first_name, "Janek")
|
||||
self.assertEqual(test.studentprofile.birth_date, test_date)
|
||||
|
||||
|
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
Loading…
Reference in New Issue
Block a user