From eee1b4579602f168725618d566346e13163ea9e9 Mon Sep 17 00:00:00 2001 From: Masoud Azizi Date: Wed, 18 Dec 2019 01:25:14 -0800 Subject: [PATCH] All python packages upgraded to latest version(django 1 to 3) --- ._.DS_Store | Bin 4096 -> 0 bytes .gitignore | 2 +- README.md | 2 +- bestoon/asgi.py | 16 +++++++++ bestoon/settings.py.sample | 18 +++++----- bestoon/urls.py | 16 +++++---- bestoon/wsgi.py | 4 +-- manage.py | 29 ++++++++------- requirements.txt | 15 +++++--- web/._.DS_Store | Bin 4096 -> 0 bytes web/.coafile | 3 -- web/migrations/0001_initial.py | 42 ++++++++++++++++++++-- web/migrations/0002_income.py | 28 --------------- web/migrations/0003_user.py | 35 ------------------ web/migrations/0004_auto_20161223_1242.py | 38 -------------------- web/migrations/0005_passwordresetcodes.py | 26 -------------- web/migrations/0006_auto_20170122_1738.py | 29 --------------- web/migrations/0007_auto_20170122_1758.py | 20 ----------- web/migrations/0008_auto_20170122_1759.py | 20 ----------- web/migrations/0009_auto_20170122_1804.py | 20 ----------- web/migrations/0010_auto_20170122_1922.py | 20 ----------- web/models.py | 4 +-- web/templates/index.html | 2 +- web/templates/login.html | 2 +- web/templates/register.html | 4 +-- web/templates/resetpassword.html | 2 +- web/templates/template.html | 2 +- web/tests.py | 3 ++ web/views.py | 13 ++++--- 29 files changed, 119 insertions(+), 296 deletions(-) delete mode 100644 ._.DS_Store create mode 100644 bestoon/asgi.py delete mode 100644 web/._.DS_Store delete mode 100644 web/.coafile delete mode 100644 web/migrations/0002_income.py delete mode 100644 web/migrations/0003_user.py delete mode 100644 web/migrations/0004_auto_20161223_1242.py delete mode 100644 web/migrations/0005_passwordresetcodes.py delete mode 100644 web/migrations/0006_auto_20170122_1738.py delete mode 100644 web/migrations/0007_auto_20170122_1758.py delete mode 100644 web/migrations/0008_auto_20170122_1759.py delete mode 100644 web/migrations/0009_auto_20170122_1804.py delete mode 100644 web/migrations/0010_auto_20170122_1922.py create mode 100644 web/tests.py diff --git a/._.DS_Store b/._.DS_Store deleted file mode 100644 index 8ac37fc9adc12c023d85488dfaf3036e73962005..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4096 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIk*Y|peR=07!nd> zJ?rFuhz^DdtcpejM?+vV1V%$(Gz3ONU^E0qLtr!nMnhmU1V%$(Gz3ONfXX4j2s96b z!9Xq~BePhcD784hv?w`MAuYcsTOl*ABsH%jGe0jeC#O;&CpE1^At@&@FB{m^h3Xp8 P6srH>UXfvt`~M#R%-A0@ diff --git a/.gitignore b/.gitignore index edd432d..d787685 100644 --- a/.gitignore +++ b/.gitignore @@ -100,4 +100,4 @@ ENV/ bestoon/settings.py *.orig -.DS_Store +*.DS_Store diff --git a/README.md b/README.md index 7f6e4bb..3662f16 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ To run Bestoon in development mode; Just use steps below: ## Run On Windows If You're On A Windows Machine , Make Environment Ready By Following Steps Below: -1. Install `python2`, `pip`, `virtualenv` +1. Install `python2`, `pip`, `virtualenv` 2. Clone the project using: `git clone https://github.com/jadijadi/bestoon`. 3. Make Environment Ready Like This: ``` Command Prompt diff --git a/bestoon/asgi.py b/bestoon/asgi.py new file mode 100644 index 0000000..4709406 --- /dev/null +++ b/bestoon/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for bestoon project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bestoon.settings') + +application = get_asgi_application() diff --git a/bestoon/settings.py.sample b/bestoon/settings.py.sample index 45d586b..d273c56 100644 --- a/bestoon/settings.py.sample +++ b/bestoon/settings.py.sample @@ -1,13 +1,13 @@ """ Django settings for bestoon project. -Generated by 'django-admin startproject' using Django 1.10.4. +Generated by 'django-admin startproject' using Django 3.0. For more information on this file, see -https://docs.djangoproject.com/en/1.10/topics/settings/ +https://docs.djangoproject.com/en/3.0/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/1.10/ref/settings/ +https://docs.djangoproject.com/en/3.0/ref/settings/ """ import os @@ -17,10 +17,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'ees#cr8y%!0o=%8r2wbxcgcz0u8s!&91=b2f@a_c%&4*c&ey&a' +SECRET_KEY = '_9unun*x3vp&x%(^g3torgh7=)&uno3oez&4tw*c6tfi2)gdj^' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -74,7 +74,7 @@ WSGI_APPLICATION = 'bestoon.wsgi.application' # Database -# https://docs.djangoproject.com/en/1.10/ref/settings/#databases +# https://docs.djangoproject.com/en/3.0/ref/settings/#databases DATABASES = { 'default': { @@ -85,7 +85,7 @@ DATABASES = { # Password validation -# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -104,7 +104,7 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization -# https://docs.djangoproject.com/en/1.10/topics/i18n/ +# https://docs.djangoproject.com/en/3.0/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -118,7 +118,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.10/howto/static-files/ +# https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_URL = '/static/' diff --git a/bestoon/urls.py b/bestoon/urls.py index ff014e8..91d0e69 100644 --- a/bestoon/urls.py +++ b/bestoon/urls.py @@ -1,22 +1,24 @@ """bestoon URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/1.10/topics/http/urls/ + https://docs.djangoproject.com/en/3.0/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') + 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf - 1. Import the include() function: from django.conf.urls import url, include - 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.conf.urls import url, include from django.contrib import admin +from django.urls import path +from django.conf.urls import url, include urlpatterns = [ - url(r'^admin/', admin.site.urls), + path('admin/', admin.site.urls), url(r'', include('web.urls')), + ] diff --git a/bestoon/wsgi.py b/bestoon/wsgi.py index 82bb954..7437c43 100644 --- a/bestoon/wsgi.py +++ b/bestoon/wsgi.py @@ -4,13 +4,13 @@ It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bestoon.settings") +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bestoon.settings') application = get_wsgi_application() diff --git a/manage.py b/manage.py index 24ce1e5..bf4b246 100644 --- a/manage.py +++ b/manage.py @@ -1,22 +1,21 @@ #!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" import os import sys -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bestoon.settings") + +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bestoon.settings') try: from django.core.management import execute_from_command_line - except ImportError: - # The above import may fail for some other reason. Ensure that the - # issue is really that Django is missing to avoid masking other - # exceptions on Python 2. - try: - import django - except ImportError: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) - raise + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/requirements.txt b/requirements.txt index 4268495..f48b8c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,11 @@ -Django==1.11.23 -python-postmark==0.4.10 -requests==2.12.4 -django-cors-middleware +asgiref==3.2.3 +certifi==2019.11.28 +chardet==3.0.4 +Django==3.0 +django-cors-middleware==1.5.0 +idna==2.8 +python-postmark==0.5.1 +pytz==2019.3 +requests==2.22.0 +sqlparse==0.3.0 +urllib3==1.25.7 diff --git a/web/._.DS_Store b/web/._.DS_Store deleted file mode 100644 index 8ac37fc9adc12c023d85488dfaf3036e73962005..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4096 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIk*Y|peR=07!nd> zJ?rFuhz^DdtcpejM?+vV1V%$(Gz3ONU^E0qLtr!nMnhmU1V%$(Gz3ONfXX4j2s96b z!9Xq~BePhcD784hv?w`MAuYcsTOl*ABsH%jGe0jeC#O;&CpE1^At@&@FB{m^h3Xp8 P6srH>UXfvt`~M#R%-A0@ diff --git a/web/.coafile b/web/.coafile deleted file mode 100644 index 9299663..0000000 --- a/web/.coafile +++ /dev/null @@ -1,3 +0,0 @@ -[Default] -bears = PEP8Bear -files = *.py diff --git a/web/migrations/0001_initial.py b/web/migrations/0001_initial.py index 8342983..1f5ef0a 100644 --- a/web/migrations/0001_initial.py +++ b/web/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2016-12-20 12:28 -from __future__ import unicode_literals +# Generated by Django 3.0 on 2019-12-18 07:29 from django.conf import settings from django.db import migrations, models @@ -16,6 +14,44 @@ class Migration(migrations.Migration): ] operations = [ + migrations.CreateModel( + name='News', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=250)), + ('text', models.TextField()), + ('date', models.DateTimeField()), + ], + ), + migrations.CreateModel( + name='Passwordresetcodes', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('code', models.CharField(max_length=32)), + ('email', models.CharField(max_length=120)), + ('time', models.DateTimeField()), + ('username', models.CharField(max_length=50)), + ('password', models.CharField(max_length=50)), + ], + ), + migrations.CreateModel( + name='Token', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('token', models.CharField(max_length=48)), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Income', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.CharField(max_length=255)), + ('date', models.DateTimeField()), + ('amount', models.BigIntegerField()), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), migrations.CreateModel( name='Expense', fields=[ diff --git a/web/migrations/0002_income.py b/web/migrations/0002_income.py deleted file mode 100644 index 67e2b27..0000000 --- a/web/migrations/0002_income.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2016-12-21 07:40 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('web', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='Income', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('text', models.CharField(max_length=255)), - ('date', models.DateTimeField()), - ('amount', models.BigIntegerField()), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/web/migrations/0003_user.py b/web/migrations/0003_user.py deleted file mode 100644 index 67147f7..0000000 --- a/web/migrations/0003_user.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2016-12-23 07:44 -from __future__ import unicode_literals - -from django.conf import settings -import django.contrib.auth.models -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('auth', '0008_alter_user_username_max_length'), - ('web', '0002_income'), - ] - - operations = [ - migrations.CreateModel( - name='User', - fields=[ - ('user_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)), - ('token', models.CharField(max_length=48)), - ], - options={ - 'abstract': False, - 'verbose_name': 'user', - 'verbose_name_plural': 'users', - }, - bases=('auth.user',), - managers=[ - ('objects', django.contrib.auth.models.UserManager()), - ], - ), - ] diff --git a/web/migrations/0004_auto_20161223_1242.py b/web/migrations/0004_auto_20161223_1242.py deleted file mode 100644 index a716adb..0000000 --- a/web/migrations/0004_auto_20161223_1242.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2016-12-23 12:42 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('admin', '0002_logentry_remove_auto_add'), - ('web', '0003_user'), - ] - - operations = [ - migrations.CreateModel( - name='Token', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('token', models.CharField(max_length=48)), - ], - ), - migrations.RemoveField( - model_name='user', - name='user_ptr', - ), - migrations.DeleteModel( - name='User', - ), - migrations.AddField( - model_name='token', - name='user', - field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/web/migrations/0005_passwordresetcodes.py b/web/migrations/0005_passwordresetcodes.py deleted file mode 100644 index 396840c..0000000 --- a/web/migrations/0005_passwordresetcodes.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2016-12-25 05:54 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('web', '0004_auto_20161223_1242'), - ] - - operations = [ - migrations.CreateModel( - name='Passwordresetcodes', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('code', models.CharField(max_length=32)), - ('email', models.CharField(max_length=120)), - ('time', models.DateTimeField()), - ('username', models.CharField(max_length=50)), - ('password', models.CharField(max_length=50)), - ], - ), - ] diff --git a/web/migrations/0006_auto_20170122_1738.py b/web/migrations/0006_auto_20170122_1738.py deleted file mode 100644 index db33c99..0000000 --- a/web/migrations/0006_auto_20170122_1738.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2017-01-22 17:38 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('web', '0005_passwordresetcodes'), - ] - - operations = [ - migrations.CreateModel( - name='News', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.CharField(max_length=250)), - ('text', models.TextField()), - ('date', models.DateTimeField()), - ], - ), - migrations.AlterField( - model_name='token', - name='token', - field=models.CharField(default='FKqADlkZ5nzL1x4Z9oEv5FBxFHRAmok3idUtM0QZokOZhkEF', max_length=48), - ), - ] diff --git a/web/migrations/0007_auto_20170122_1758.py b/web/migrations/0007_auto_20170122_1758.py deleted file mode 100644 index c1de2f6..0000000 --- a/web/migrations/0007_auto_20170122_1758.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2017-01-22 17:58 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('web', '0006_auto_20170122_1738'), - ] - - operations = [ - migrations.AlterField( - model_name='token', - name='token', - field=models.CharField(default='aFLGQO8DyvsapBscilBtCN7ziY9QYnW1mJY31sYSwXySVdnd', max_length=48), - ), - ] diff --git a/web/migrations/0008_auto_20170122_1759.py b/web/migrations/0008_auto_20170122_1759.py deleted file mode 100644 index 462e178..0000000 --- a/web/migrations/0008_auto_20170122_1759.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2017-01-22 17:59 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('web', '0007_auto_20170122_1758'), - ] - - operations = [ - migrations.AlterField( - model_name='token', - name='token', - field=models.CharField(default='mdCjnKmC1YeA3cgVVJ75yp9gjTsvV1H5X8cV2FOxzgkotolj', max_length=48), - ), - ] diff --git a/web/migrations/0009_auto_20170122_1804.py b/web/migrations/0009_auto_20170122_1804.py deleted file mode 100644 index 532ed5e..0000000 --- a/web/migrations/0009_auto_20170122_1804.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2017-01-22 18:04 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('web', '0008_auto_20170122_1759'), - ] - - operations = [ - migrations.AlterField( - model_name='token', - name='token', - field=models.CharField(default='DTjREU45fVlqD0Fl2FFFaxrYfEmYXNdVJ3BewPh8tW5tHExp', max_length=48), - ), - ] diff --git a/web/migrations/0010_auto_20170122_1922.py b/web/migrations/0010_auto_20170122_1922.py deleted file mode 100644 index 6792282..0000000 --- a/web/migrations/0010_auto_20170122_1922.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.4 on 2017-01-22 19:22 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('web', '0009_auto_20170122_1804'), - ] - - operations = [ - migrations.AlterField( - model_name='token', - name='token', - field=models.CharField(max_length=48), - ), - ] diff --git a/web/models.py b/web/models.py index 14ed45c..aba4c94 100644 --- a/web/models.py +++ b/web/models.py @@ -32,7 +32,7 @@ class Expense(models.Model): text = models.CharField(max_length=255) date = models.DateTimeField() amount = models.BigIntegerField() - user = models.ForeignKey(User) + user = models.ForeignKey(User, on_delete=models.CASCADE,) def __unicode__(self): return "{}-{}-{}".format(self.date, self.user, self.amount) @@ -42,7 +42,7 @@ class Income(models.Model): text = models.CharField(max_length=255) date = models.DateTimeField() amount = models.BigIntegerField() - user = models.ForeignKey(User) + user = models.ForeignKey(User, on_delete=models.CASCADE,) def __unicode__(self): return "{}-{}-{}".format(self.date, self.user, self.amount) diff --git a/web/templates/index.html b/web/templates/index.html index 8bb8b32..bb31661 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -1,5 +1,5 @@ {% extends "template.html"%} -{% load staticfiles %} +{% load static %} {% block content %} diff --git a/web/templates/login.html b/web/templates/login.html index 3b3af47..577f18d 100644 --- a/web/templates/login.html +++ b/web/templates/login.html @@ -1,5 +1,5 @@ {% extends "template.html"%} -{% load staticfiles %} +{% load static %} {% block content %}
diff --git a/web/templates/register.html b/web/templates/register.html index 33e0a04..8eff2cb 100644 --- a/web/templates/register.html +++ b/web/templates/register.html @@ -1,5 +1,5 @@ {% extends "template.html"%} -{% load staticfiles %} +{% load static %} {% block content %} @@ -75,7 +75,7 @@

ثبت نام

-
+
diff --git a/web/templates/resetpassword.html b/web/templates/resetpassword.html index d6daa88..6d6ccd0 100644 --- a/web/templates/resetpassword.html +++ b/web/templates/resetpassword.html @@ -1,5 +1,5 @@ {% extends "template.html"%} -{% load staticfiles %} +{% load static %} {% block content %} diff --git a/web/templates/template.html b/web/templates/template.html index bf72fea..efc138b 100644 --- a/web/templates/template.html +++ b/web/templates/template.html @@ -1,4 +1,4 @@ -{% load staticfiles %} +{% load static %} diff --git a/web/tests.py b/web/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/web/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/web/views.py b/web/views.py index ae78883..1e9c734 100644 --- a/web/views.py +++ b/web/views.py @@ -43,7 +43,7 @@ def news(request): @require_POST def login(request): # check if POST objects has username and password - if request.POST.has_key('username') and request.POST.has_key('password'): + if 'username' in request.POST and 'password' in request.POST: username = request.POST['username'] password = request.POST['password'] this_user = get_object_or_404(User, username=username) @@ -66,8 +66,7 @@ def login(request): def register(request): - if request.POST.has_key( - 'requestcode'): # form is filled. if not spam, generate code and save in db, wait for email confirmation, return message + if 'requestcode' in request.POST: # form is filled. if not spam, generate code and save in db, wait for email confirmation, return message # is this spam? check reCaptcha if not grecaptcha_verify(request): # captcha was not correct context = { @@ -110,7 +109,7 @@ def register(request): 'message': 'متاسفانه این نام کاربری قبلا استفاده شده است. از نام کاربری دیگری استفاده کنید. ببخشید که فرم ذخیره نشده. درست می شه'} # TODO: forgot password # TODO: keep the form data return render(request, 'register.html', context) - elif request.GET.has_key('code'): # user clicked on code + elif 'code' in request.GET: # user clicked on code code = request.GET['code'] if Passwordresetcodes.objects.filter( code=code).exists(): # if code is in temporary db, read the data and create the user @@ -140,7 +139,7 @@ def register(request): @csrf_exempt @require_POST def whoami(request): - if request.POST.has_key('token'): + if 'token' in request.POST: this_token = request.POST['token'] # TODO: Check if there is no `token`- done-please Check it # Check if there is a user with this token; will retun 404 instead. this_user = get_object_or_404(User, token__token=this_token) @@ -220,7 +219,7 @@ def edit_expense(request): this_pk = request.POST['id'] if 'id' in request.POST else "-1" this_token = request.POST['token'] if 'token' in request.POST else "" this_user = get_object_or_404(User, token__token=this_token) - + this_expense = get_object_or_404(Expense, pk=this_pk, user=this_user) this_expense.text = this_text this_expense.amount = this_amount @@ -232,7 +231,7 @@ def edit_expense(request): @csrf_exempt @require_POST def edit_income(request): - """ edit an income """ + """ edit an income """ this_text = request.POST['text'] if 'text' in request.POST else "" this_amount = request.POST['amount'] if 'amount' in request.POST else "0" this_pk = request.POST['id'] if 'id' in request.POST else "0"