diff --git a/requirements/base.in b/requirements/base.in index 442a003143dbc7afde0dac219361683a666615e2..d38f35becf4d4f536496f0838654018c439ffb26 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -1,3 +1,4 @@ -Django==1.11.5 -djangorestframework==3.6.4 +Django==2.0.1 +djangorestframework==3.7.7 django-social-authsch==0.1 +django-solo==1.1.3 diff --git a/requirements/development.in b/requirements/development.in index a947995cb351da9beb9a48c88383fcfba97354f2..d80fc6250c3504682e90f62fdf9abfed415f824c 100644 --- a/requirements/development.in +++ b/requirements/development.in @@ -1,4 +1,5 @@ -r base.in flake8==3.4.1 pip-tools==1.9.0 -django-extensions==1.9.1 +django-extensions==1.9.9 +python-language-server==0.13.0 diff --git a/requirements/development.txt b/requirements/development.txt index 68babd8a27fcd1363a821912246752fa0a828d66..2806f075fd5fcbc4a0f09bead0d99fff22a3401b 100644 --- a/requirements/development.txt +++ b/requirements/development.txt @@ -7,25 +7,38 @@ certifi==2017.7.27.1 # via requests chardet==3.0.4 # via requests click==6.7 # via pip-tools +configparser==3.5.0 # via python-language-server defusedxml==0.5.0 # via python3-openid, social-auth-core -django-extensions==1.9.1 +django-extensions==1.9.9 django-social-authsch==0.1 -django==1.11.5 -djangorestframework==3.6.4 +django-solo==1.1.3 +django==2.0.1 +djangorestframework==3.7.7 first==2.0.1 # via pip-tools flake8==3.4.1 +future==0.16.0 # via python-language-server idna==2.6 # via requests -mccabe==0.6.1 # via flake8 +jedi==0.11.1 # via python-language-server +json-rpc==1.10.8 # via python-language-server +mccabe==0.6.1 # via flake8, python-language-server oauthlib==2.0.6 # via requests-oauthlib, social-auth-core +parso==0.1.1 # via jedi pip-tools==1.9.0 -pycodestyle==2.3.1 # via flake8 -pyflakes==1.5.0 # via flake8 +pluggy==0.6.0 # via python-language-server +pycodestyle==2.3.1 # via flake8, python-language-server +pydocstyle==2.1.1 # via python-language-server +pyflakes==1.5.0 # via flake8, python-language-server pyjwt==1.5.3 # via social-auth-core +python-language-server==0.13.0 python3-openid==3.1.0 # via social-auth-core pytz==2017.2 # via django requests-oauthlib==0.8.0 # via social-auth-core requests==2.18.4 # via requests-oauthlib, social-auth-core -six==1.10.0 # via django-extensions, pip-tools, social-auth-app-django, social-auth-core +rope==0.10.7 # via python-language-server +six==1.10.0 # via django-extensions, pip-tools, pydocstyle, social-auth-app-django, social-auth-core +snowballstemmer==1.2.1 # via pydocstyle social-auth-app-django==2.0.0 # via django-social-authsch social-auth-core==1.5.0 # via django-social-authsch, social-auth-app-django +typing==3.6.4 # via django-extensions urllib3==1.22 # via requests +yapf==0.20.1 # via python-language-server diff --git a/requirements/production.in b/requirements/production.in new file mode 100644 index 0000000000000000000000000000000000000000..00a73eea0fce88f6ffa4c793be6b1966a47d95b8 --- /dev/null +++ b/requirements/production.in @@ -0,0 +1,2 @@ +-r base.in +gunicorn==19.7.1 diff --git a/requirements/production.txt b/requirements/production.txt new file mode 100644 index 0000000000000000000000000000000000000000..31199b03b9b308ed7759df6e635f9971d07e2ed5 --- /dev/null +++ b/requirements/production.txt @@ -0,0 +1,25 @@ +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile --output-file production.txt production.in +# +certifi==2018.1.18 # via requests +chardet==3.0.4 # via requests +defusedxml==0.5.0 # via python3-openid, social-auth-core +django-social-authsch==0.1 +django-solo==1.1.3 +django==2.0.1 +djangorestframework==3.7.7 +gunicorn==19.7.1 +idna==2.6 # via requests +oauthlib==2.0.6 # via requests-oauthlib, social-auth-core +pyjwt==1.5.3 # via social-auth-core +python3-openid==3.1.0 # via social-auth-core +pytz==2017.3 # via django +requests-oauthlib==0.8.0 # via social-auth-core +requests==2.18.4 # via requests-oauthlib, social-auth-core +six==1.11.0 # via social-auth-app-django, social-auth-core +social-auth-app-django==2.1.0 # via django-social-authsch +social-auth-core==1.6.0 # via django-social-authsch, social-auth-app-django +urllib3==1.22 # via requests diff --git a/src/homework/migrations/0005_auto_20180126_0135.py b/src/homework/migrations/0005_auto_20180126_0135.py new file mode 100644 index 0000000000000000000000000000000000000000..0155be9f4f3740b5aca421362a0b57b429fcd737 --- /dev/null +++ b/src/homework/migrations/0005_auto_20180126_0135.py @@ -0,0 +1,20 @@ +# Generated by Django 2.0.1 on 2018-01-26 00:35 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('homework', '0004_auto_20180125_1817'), + ] + + operations = [ + migrations.AlterField( + model_name='task', + name='created_by', + field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/src/homework/models.py b/src/homework/models.py index 87772df30ab9d524475153825894519cac862e17..5a8b2026a6deb3909a5129278e4695b58bcf47ba 100644 --- a/src/homework/models.py +++ b/src/homework/models.py @@ -21,11 +21,11 @@ def validate_deadline(date): # raise ValidationError(_('Please keep filesize under' + __MAX_UPLOAD_SIZE)) class Task(models.Model): - title = models.CharField(max_length=150, ) - date = models.DateTimeField(auto_now_add=True, editable=False, ) - deadline = models.DateTimeField(validators=[validate_deadline], ) + title = models.CharField(max_length=150) + date = models.DateTimeField(auto_now_add=True, editable=False) + deadline = models.DateTimeField(validators=[validate_deadline]) text = models.TextField() - created_by = models.ForeignKey(User, ) + created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING) files = models.FileField( validators=[validators.FileExtensionValidator( 'image/png', @@ -48,11 +48,11 @@ class Task(models.Model): class Solution(models.Model): - task = models.ForeignKey(Task, related_name='task_solution', on_delete=models.CASCADE, ) + task = models.ForeignKey(Task, related_name='task_solution', on_delete=models.CASCADE) # student = models.ForeignKey(account.models.Profile, related_name='student_solution', on_delete=models.CASCADE) - date = models.DateTimeField(auto_now_add=True, editable=False, ) - ready = models.BooleanField(default=False, ) # if(Soulution.date <= Task.deadline) - accepted = models.BooleanField(default=False, ) + date = models.DateTimeField(auto_now_add=True, editable=False) + ready = models.BooleanField(default=False) # if(Soulution.date <= Task.deadline) + accepted = models.BooleanField(default=False) files = models.FileField( validators=[validators.FileExtensionValidator( 'image/png', @@ -61,7 +61,7 @@ class Solution(models.Model): )], blank=True, ) - created_by = models.ForeignKey(User, ) + created_by = models.ForeignKey(User, on_delete=models.CASCADE) # files = myfields.RestrictedFileField( # content_types=['image/png', 'image/jpeg', 'application/zip'], # max_upload_size=MAX_UPLOAD_SIZE, diff --git a/src/homework/permissions.py b/src/homework/permissions.py index ef5e09c427b4f93fac2592d1043a828f32d05c3d..8c1bc6a6dcca2ecdcfc18a7c12d47a80d3304861 100644 --- a/src/homework/permissions.py +++ b/src/homework/permissions.py @@ -8,11 +8,7 @@ class IsStaffOrReadOnly(BasePermission): """ def has_permission(self, request, view): - return ( - request.method in SAFE_METHODS or - request.user and - request.user.is_staff - ) + return request.method in SAFE_METHODS or request.user and request.user.is_staff class IsAuthenticatedOrReadOnly(BasePermission): @@ -21,11 +17,7 @@ class IsAuthenticatedOrReadOnly(BasePermission): """ def has_permission(self, request, view): - return ( - request.method in SAFE_METHODS or - request.user and - request.user.is_authenticated - ) + return request.method in SAFE_METHODS or request.user and request.user.is_authenticated class IsStaffOrReadOnlyForAuthenticated(BasePermission): @@ -34,8 +26,4 @@ class IsStaffOrReadOnlyForAuthenticated(BasePermission): The request is authenticated as a staff, or is a read-only request for authenticated. """ def has_permission(self, request, view): - return ( - request.user.is_staff or - request.method in SAFE_METHODS and - request.user.is_authenticated - ) + return request.user.is_staff or request.method in SAFE_METHODS and request.user.is_authenticated diff --git a/src/news/migrations/0003_auto_20180126_0135.py b/src/news/migrations/0003_auto_20180126_0135.py new file mode 100644 index 0000000000000000000000000000000000000000..744aef9118bc2963df22d62ea5af9c8230adf26c --- /dev/null +++ b/src/news/migrations/0003_auto_20180126_0135.py @@ -0,0 +1,29 @@ +# Generated by Django 2.0.1 on 2018-01-26 00:35 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('news', '0002_auto_20171220_1852'), + ] + + operations = [ + migrations.RenameField( + model_name='article', + old_name='date', + new_name='created_at', + ), + migrations.AddField( + model_name='article', + name='updated_at', + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name='article', + name='author', + field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='author', to='account.Profile'), + ), + ] diff --git a/src/news/models.py b/src/news/models.py index b30275b532f0d66b29072bbeae2f376938f6a0ec..0714bf16b3c1e24f9d9da0b476e5f8bdb04f428d 100644 --- a/src/news/models.py +++ b/src/news/models.py @@ -3,10 +3,11 @@ from account.models import Profile class Article(models.Model): - author = models.ForeignKey(Profile, related_name="author") + author = models.ForeignKey(Profile, related_name="author", on_delete=models.DO_NOTHING) title = models.CharField(null=False, max_length=200) text = models.TextField() - date = models.DateTimeField(auto_now_add=True) + created_at = models.DateTimeField(auto_now_add=True, editable=False) + updated_at = models.DateTimeField(auto_now=True, editable=False) def __str__(self): return self.title diff --git a/src/news/permissions.py b/src/news/permissions.py index af200e51fd2bded246fdff376bc667109a87f632..c8405be19c5b2c7c4df0397461142b4cdf852bf6 100644 --- a/src/news/permissions.py +++ b/src/news/permissions.py @@ -3,9 +3,5 @@ from rest_framework.permissions import SAFE_METHODS class IsStaffOrReadOnlyForAuthenticated(BasePermission): - def has_permission(self, request, view): - return (request.user.is_staff or - request.method in SAFE_METHODS and - request.user.is_authenticated - ) + return request.user.is_staff or request.method in SAFE_METHODS and request.user.is_authenticated diff --git a/src/news/serializers.py b/src/news/serializers.py index ced9a8a2bce991d678e1cac1a7d3b8a83c0c4b20..6da75f52b1e41c2bc99b1b3727c97cd6606b4453 100644 --- a/src/news/serializers.py +++ b/src/news/serializers.py @@ -5,4 +5,4 @@ from rest_framework import serializers class ArticleListSerializer(serializers.ModelSerializer): class Meta: model = Article - fields = '__all__' + fields = serializers.ALL_FIELDS diff --git a/src/news/urls.py b/src/news/urls.py index b08ebdd72a8c2303635cac63862bb8d0320e419e..d71ed82e9e76d7ee61aa6e91c0f8f868a28b1280 100644 --- a/src/news/urls.py +++ b/src/news/urls.py @@ -2,8 +2,7 @@ from rest_framework import routers from news import views -router = routers.DefaultRouter(trailing_slash=False) - +router = routers.DefaultRouter() router.register(r'news', views.NewsViewSet) urlpatterns = router.urls diff --git a/src/stats/urls.py b/src/stats/urls.py index 7c03811c1c72b2efe61eb9009f450a2047212956..ef0f4e2166c58ea7ceea950825e171cae29f6807 100644 --- a/src/stats/urls.py +++ b/src/stats/urls.py @@ -5,5 +5,4 @@ from . import views router = routers.DefaultRouter() router.register(r'events', views.KszkEventViewSet) -# app_name = 'stats' urlpatterns = router.urls