diff --git a/Pipfile b/Pipfile index 8e60571b6ab19789cf8ddfbda397be30e2485890..39e78e7d6357cce7516e2b9ab31702c36b86f3ca 100644 --- a/Pipfile +++ b/Pipfile @@ -4,11 +4,12 @@ verify_ssl = true name = "pypi" [packages] -django = "*" -django-cors-headers = "*" -djangorestframework = "*" -pillow = "*" -uwsgi = "*" +django = "==3.1.2" +djangorestframework = "==3.12.2" +Pillow = "==8.0.1" +django-cors-headers = "==3.7.0" +django-dotenv = "==1.4.2" +uwsgi = "==2.0.19.1" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 9d8d6a14c906b3b26240170a8390306e493429f0..050b3ee3c2ed91a4e7eddcbee74b17133b631bfe 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "f1ffc1e60d515d604136eec07eea7e16c697c4e5529414b3b41eb9a672871223" + "sha256": "2ba9fa9ccbc91e0595df79a5a3f97853818f286a2e0cc6726b6eb6c9b16d1189" }, "pipfile-spec": 6, "requires": { @@ -18,104 +18,99 @@ "default": { "asgiref": { "hashes": [ - "sha256:4ef1ab46b484e3c706329cedeff284a5d40824200638503f5768edb6de7d58e9", - "sha256:ffc141aa908e6f175673e7b1b3b7af4fdb0ecb738fc5c8b88f69f055c2415214" + "sha256:7e51911ee147dd685c3c8b805c0ad0cb58d360987b56953878f8c06d2d1c6f1a", + "sha256:9fc6fb5d39b8af147ba40765234fa822b39818b12cc80b35ad9b0cef3a476aed" ], - "markers": "python_version >= '3.6'", - "version": "==3.4.1" + "markers": "python_version >= '3.5'", + "version": "==3.2.10" }, "django": { "hashes": [ - "sha256:51284300f1522ffcdb07ccbdf676a307c6678659e1284f0618e5a774127a6a08", - "sha256:e22c9266da3eec7827737cde57694d7db801fedac938d252bf27377cec06ed1b" + "sha256:a2127ad0150ec6966655bedf15dbbff9697cc86d61653db2da1afa506c0b04cc", + "sha256:c93c28ccf1d094cbd00d860e83128a39e45d2c571d3b54361713aaaf9a94cac4" ], "index": "pypi", - "version": "==3.2.9" + "version": "==3.1.2" }, "django-cors-headers": { "hashes": [ - "sha256:cba6e99659abb0e47cc4aaabb8fcde03f193e6bb3b92ba47c5185ec4cedc5d9e", - "sha256:cd6f4360f5246569c149dc1c40c907c191f1ec45551e10d2a2e2e68512652f78" + "sha256:1ac2b1213de75a251e2ba04448da15f99bcfcbe164288ae6b5ff929dc49b372f", + "sha256:96069c4aaacace786a34ee7894ff680780ec2644e4268b31181044410fecd12e" + ], + "index": "pypi", + "version": "==3.7.0" + }, + "django-dotenv": { + "hashes": [ + "sha256:3812bb0f4876cf31f902aad140f0645e120e51ee30eb7c40c22050f58a0e4adb", + "sha256:a9b1b40a70bd321acd231926acedb9bd2c5e873e33a1873b34a7276d196a765e" ], "index": "pypi", - "version": "==3.10.0" + "version": "==1.4.2" }, "djangorestframework": { "hashes": [ - "sha256:6d1d59f623a5ad0509fe0d6bfe93cbdfe17b8116ebc8eda86d45f6e16e819aaf", - "sha256:f747949a8ddac876e879190df194b925c177cdeb725a099db1460872f7c0a7f2" + "sha256:0209bafcb7b5010fdfec784034f059d512256424de2a0f084cb82b096d6dd6a7", + "sha256:0898182b4737a7b584a2c73735d89816343369f259fea932d90dc78e35d8ac33" ], "index": "pypi", - "version": "==3.12.4" + "version": "==3.12.2" }, "pillow": { "hashes": [ - "sha256:066f3999cb3b070a95c3652712cffa1a748cd02d60ad7b4e485c3748a04d9d76", - "sha256:0a0956fdc5defc34462bb1c765ee88d933239f9a94bc37d132004775241a7585", - "sha256:0b052a619a8bfcf26bd8b3f48f45283f9e977890263e4571f2393ed8898d331b", - "sha256:1394a6ad5abc838c5cd8a92c5a07535648cdf6d09e8e2d6df916dfa9ea86ead8", - "sha256:1bc723b434fbc4ab50bb68e11e93ce5fb69866ad621e3c2c9bdb0cd70e345f55", - "sha256:244cf3b97802c34c41905d22810846802a3329ddcb93ccc432870243211c79fc", - "sha256:25a49dc2e2f74e65efaa32b153527fc5ac98508d502fa46e74fa4fd678ed6645", - "sha256:2e4440b8f00f504ee4b53fe30f4e381aae30b0568193be305256b1462216feff", - "sha256:3862b7256046fcd950618ed22d1d60b842e3a40a48236a5498746f21189afbbc", - "sha256:3eb1ce5f65908556c2d8685a8f0a6e989d887ec4057326f6c22b24e8a172c66b", - "sha256:3f97cfb1e5a392d75dd8b9fd274d205404729923840ca94ca45a0af57e13dbe6", - "sha256:493cb4e415f44cd601fcec11c99836f707bb714ab03f5ed46ac25713baf0ff20", - "sha256:4acc0985ddf39d1bc969a9220b51d94ed51695d455c228d8ac29fcdb25810e6e", - "sha256:5503c86916d27c2e101b7f71c2ae2cddba01a2cf55b8395b0255fd33fa4d1f1a", - "sha256:5b7bb9de00197fb4261825c15551adf7605cf14a80badf1761d61e59da347779", - "sha256:5e9ac5f66616b87d4da618a20ab0a38324dbe88d8a39b55be8964eb520021e02", - "sha256:620582db2a85b2df5f8a82ddeb52116560d7e5e6b055095f04ad828d1b0baa39", - "sha256:62cc1afda735a8d109007164714e73771b499768b9bb5afcbbee9d0ff374b43f", - "sha256:70ad9e5c6cb9b8487280a02c0ad8a51581dcbbe8484ce058477692a27c151c0a", - "sha256:72b9e656e340447f827885b8d7a15fc8c4e68d410dc2297ef6787eec0f0ea409", - "sha256:72cbcfd54df6caf85cc35264c77ede902452d6df41166010262374155947460c", - "sha256:792e5c12376594bfcb986ebf3855aa4b7c225754e9a9521298e460e92fb4a488", - "sha256:7b7017b61bbcdd7f6363aeceb881e23c46583739cb69a3ab39cb384f6ec82e5b", - "sha256:81f8d5c81e483a9442d72d182e1fb6dcb9723f289a57e8030811bac9ea3fef8d", - "sha256:82aafa8d5eb68c8463b6e9baeb4f19043bb31fefc03eb7b216b51e6a9981ae09", - "sha256:84c471a734240653a0ec91dec0996696eea227eafe72a33bd06c92697728046b", - "sha256:8c803ac3c28bbc53763e6825746f05cc407b20e4a69d0122e526a582e3b5e153", - "sha256:93ce9e955cc95959df98505e4608ad98281fff037350d8c2671c9aa86bcf10a9", - "sha256:9a3e5ddc44c14042f0844b8cf7d2cd455f6cc80fd7f5eefbe657292cf601d9ad", - "sha256:a4901622493f88b1a29bd30ec1a2f683782e57c3c16a2dbc7f2595ba01f639df", - "sha256:a5a4532a12314149d8b4e4ad8ff09dde7427731fcfa5917ff16d0291f13609df", - "sha256:b8831cb7332eda5dc89b21a7bce7ef6ad305548820595033a4b03cf3091235ed", - "sha256:b8e2f83c56e141920c39464b852de3719dfbfb6e3c99a2d8da0edf4fb33176ed", - "sha256:c70e94281588ef053ae8998039610dbd71bc509e4acbc77ab59d7d2937b10698", - "sha256:c8a17b5d948f4ceeceb66384727dde11b240736fddeda54ca740b9b8b1556b29", - "sha256:d82cdb63100ef5eedb8391732375e6d05993b765f72cb34311fab92103314649", - "sha256:d89363f02658e253dbd171f7c3716a5d340a24ee82d38aab9183f7fdf0cdca49", - "sha256:d99ec152570e4196772e7a8e4ba5320d2d27bf22fdf11743dd882936ed64305b", - "sha256:ddc4d832a0f0b4c52fff973a0d44b6c99839a9d016fe4e6a1cb8f3eea96479c2", - "sha256:e3dacecfbeec9a33e932f00c6cd7996e62f53ad46fbe677577394aaa90ee419a", - "sha256:eb9fc393f3c61f9054e1ed26e6fe912c7321af2f41ff49d3f83d05bacf22cc78" + "sha256:006de60d7580d81f4a1a7e9f0173dc90a932e3905cc4d47ea909bc946302311a", + "sha256:0a2e8d03787ec7ad71dc18aec9367c946ef8ef50e1e78c71f743bc3a770f9fae", + "sha256:0eeeae397e5a79dc088d8297a4c2c6f901f8fb30db47795113a4a605d0f1e5ce", + "sha256:11c5c6e9b02c9dac08af04f093eb5a2f84857df70a7d4a6a6ad461aca803fb9e", + "sha256:2fb113757a369a6cdb189f8df3226e995acfed0a8919a72416626af1a0a71140", + "sha256:4b0ef2470c4979e345e4e0cc1bbac65fda11d0d7b789dbac035e4c6ce3f98adb", + "sha256:59e903ca800c8cfd1ebe482349ec7c35687b95e98cefae213e271c8c7fffa021", + "sha256:5abd653a23c35d980b332bc0431d39663b1709d64142e3652890df4c9b6970f6", + "sha256:5f9403af9c790cc18411ea398a6950ee2def2a830ad0cfe6dc9122e6d528b302", + "sha256:6b4a8fd632b4ebee28282a9fef4c341835a1aa8671e2770b6f89adc8e8c2703c", + "sha256:6c1aca8231625115104a06e4389fcd9ec88f0c9befbabd80dc206c35561be271", + "sha256:795e91a60f291e75de2e20e6bdd67770f793c8605b553cb6e4387ce0cb302e09", + "sha256:7ba0ba61252ab23052e642abdb17fd08fdcfdbbf3b74c969a30c58ac1ade7cd3", + "sha256:7c9401e68730d6c4245b8e361d3d13e1035cbc94db86b49dc7da8bec235d0015", + "sha256:81f812d8f5e8a09b246515fac141e9d10113229bc33ea073fec11403b016bcf3", + "sha256:895d54c0ddc78a478c80f9c438579ac15f3e27bf442c2a9aa74d41d0e4d12544", + "sha256:8de332053707c80963b589b22f8e0229f1be1f3ca862a932c1bcd48dafb18dd8", + "sha256:92c882b70a40c79de9f5294dc99390671e07fc0b0113d472cbea3fde15db1792", + "sha256:95edb1ed513e68bddc2aee3de66ceaf743590bf16c023fb9977adc4be15bd3f0", + "sha256:b63d4ff734263ae4ce6593798bcfee6dbfb00523c82753a3a03cbc05555a9cc3", + "sha256:bd7bf289e05470b1bc74889d1466d9ad4a56d201f24397557b6f65c24a6844b8", + "sha256:cc3ea6b23954da84dbee8025c616040d9aa5eaf34ea6895a0a762ee9d3e12e11", + "sha256:cc9ec588c6ef3a1325fa032ec14d97b7309db493782ea8c304666fb10c3bd9a7", + "sha256:d3d07c86d4efa1facdf32aa878bd508c0dc4f87c48125cc16b937baa4e5b5e11", + "sha256:d8a96747df78cda35980905bf26e72960cba6d355ace4780d4bdde3b217cdf1e", + "sha256:e38d58d9138ef972fceb7aeec4be02e3f01d383723965bfcef14d174c8ccd039", + "sha256:eb472586374dc66b31e36e14720747595c2b265ae962987261f044e5cce644b5", + "sha256:fbd922f702582cb0d71ef94442bfca57624352622d75e3be7a1e7e9360b07e72" ], "index": "pypi", - "version": "==8.4.0" + "version": "==8.0.1" }, "pytz": { "hashes": [ - "sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c", - "sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326" + "sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da", + "sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798" ], - "version": "==2021.3" + "version": "==2021.1" }, "sqlparse": { "hashes": [ - "sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae", - "sha256:48719e356bb8b42991bdbb1e8b83223757b93789c00910a616a071910ca4a64d" + "sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0", + "sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8" ], "markers": "python_version >= '3.5'", - "version": "==0.4.2" + "version": "==0.4.1" }, "uwsgi": { "hashes": [ - "sha256:88ab9867d8973d8ae84719cf233b7dafc54326fcaec89683c3f9f77c002cdff9" + "sha256:faa85e053c0b1be4d5585b0858d3a511d2cd10201802e8676060fd0a109e5869" ], "index": "pypi", - "version": "==2.0.20" + "version": "==2.0.19.1" } }, "develop": {} diff --git a/README.md b/README.md index bce1a47864659f837d009c27a232c9287f06a036..6c32fcb53bc5008b9c9880465b4b7097d18959d0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,69 @@ # The Social Network -TBA \ No newline at end of file +`the_social_network/` is the backend of the most thinkable fronted for social networks, which was developed with [Django](https://www.djangoproject.com/) and [Django Rest Framework](https://www.django-rest-framework.org/) + +This subproject is the basis for any possible type of social networks. + +The `core/` subfolder is the core of this project an is managed to working as a starting point for any further works on basic social networks. + +Use the [Postman-Documentation](https://documenter.getpostman.com/view/13331140/TzRNFVaC) and run it locally for a detailed overview about the API. +Make sure the database is seeded with corresponding data. + +## Requirements + +Before using this project one must create the corresponding virtual environment if there is none. +Otherwise the virtual environment can be joined with the same command: + + $ pipenv shell + +If the dependencies listed in `Pipfile` are not installed in the virtual environment they can be installed by using: + + $ pipenv install + +If the database is not existent then the following command can be used to make all existing migrations: + + $ pipenv run python manage.py migrate + +Afterwards this project should be ready to use. + +## Environment + +Before one can start this project a environment file must be defined regarding the mode in which this project should operate in. +Therefore the variables inside `.env` can be changed accordingly. + +| Variable | Development | Production | Use | +|:--------------------:|:-----------:|:-------------------:|:----------------------------------------------------------------------:| +| CORS_ORIGIN_ALLOW_ALL| True | False | Turn on/off cross-origin resource sharing | +| DEBUG | True | False | For turn on/off the debug mode and the corresponding debug logging | +| DJANGO_ALLOWED_HOSTS | * | tsn.marc-feger.de | List of strings representing the host/domain names this site can serve | +| SECRET_KEY | ------ | ------ | For cryptographic signing. Should be a unique, unpredictable value. | + +### Development + +For the development mode of this project one must specify an `.env` file like specified in the table above. +Any code changes will we validated and added after the automated refresh of the running service. + +To start this project the following command can be used: + + $ pipenv run python manage.py runserver + +### Database + +If any new database model has been added to the project one must add the migrations with: + + $ pipenv run python manage.py makemigrations + +To make those migrations visible and to add them permanently to the database one must use: + + $ pipenv run python manage.py migrate + +### Testing + +Each application in this project contains test to validate the working code of this project. +To test everything one can use: + + $ pipenv run python manage.py test + +To test specific applications one can use: + + $ pipenv run python manage.py test <e.g. accounts or contents ...> diff --git a/the_social_network/the_social_network/settings.py b/the_social_network/the_social_network/settings.py index f19f1ca7142d95bd8b298c2155864d72f63a29f7..84842f0bb7c73cd4aeb6610905a55b97d69e4be3 100644 --- a/the_social_network/the_social_network/settings.py +++ b/the_social_network/the_social_network/settings.py @@ -1,14 +1,15 @@ """ Django settings for the_social_network project. -Generated by 'django-admin startproject' using Django 3.2.9. +Generated by 'django-admin startproject' using Django 3.1.2. For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ +https://docs.djangoproject.com/en/3.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ +https://docs.djangoproject.com/en/3.1/ref/settings/ """ +import logging import os from pathlib import Path @@ -16,18 +17,20 @@ from pathlib import Path BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-hpjug(8bb2&mx*lv-$h!a6ried17*-34or7ngwee*1x#f6kak^' +SECRET_KEY = os.environ.get("SECRET_KEY", "MySecretSecret") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = os.environ.get("DEBUG", True) -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "*").split(",") -# Application definition +CORS_ORIGIN_ALLOW_ALL = bool(os.environ.get("CORS_ORIGIN_ALLOW_ALL", True)) +# CORS_ORIGIN_WHITELIST = os.environ.get("CORS_ORIGIN_WHITELIST", "*").split(",") +# Application definition INSTALLED_APPS = [ 'django.contrib.admin', @@ -74,7 +77,7 @@ TEMPLATES = [ WSGI_APPLICATION = 'the_social_network.wsgi.application' # Database -# https://docs.djangoproject.com/en/3.2/ref/settings/#databases +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases DATABASES = { 'default': { @@ -84,7 +87,7 @@ DATABASES = { } # Password validation -# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -102,7 +105,7 @@ AUTH_PASSWORD_VALIDATORS = [ ] # Internationalization -# https://docs.djangoproject.com/en/3.2/topics/i18n/ +# https://docs.djangoproject.com/en/3.1/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -115,7 +118,7 @@ USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.2/howto/static-files/ +# https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/django_static/' STATIC_ROOT = os.path.join(BASE_DIR, "django_static/") @@ -130,8 +133,3 @@ REST_FRAMEWORK = { # Folder to store media data MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') - -# Default primary key field type -# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/the_social_network/the_social_network/urls.py b/the_social_network/the_social_network/urls.py index 1acc893cfeb1de6fb679a7bedcf40ccf3f608500..a6b7db4cba1dde09a7fe801101c1db6d0e537187 100644 --- a/the_social_network/the_social_network/urls.py +++ b/the_social_network/the_social_network/urls.py @@ -20,9 +20,9 @@ from django.contrib import admin from django.urls import path, include urlpatterns = [ - path('admin/', admin.site.urls), - url(r'^authentication/', include('core.urls.authenticationUrls')), - url(r'^accounts/', include('core.urls.accountUrls')), - url(r'^search/', include('core.urls.searchUrls')), - url(r'^contents/', include('core.urls.contentUrls')), - ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + path('admin/', admin.site.urls), + url(r'^authentication/', include('core.urls.authenticationUrls')), + url(r'^accounts/', include('core.urls.accountUrls')), + url(r'^search/', include('core.urls.searchUrls')), + url(r'^contents/', include('core.urls.contentUrls')), +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)