Skip to content
Snippets Groups Projects
Unverified Commit fd150887 authored by bmate711's avatar bmate711 Committed by GitHub
Browse files

Merge branch 'master' into homework

parents 4751d3ba 9bedd50b
No related branches found
No related tags found
No related merge requests found
Showing
with 273 additions and 15 deletions
version: 2
jobs:
build:
working_directory: ~/kszkepzes
docker:
- image: circleci/python:3.6.4
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages
- restore_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- run:
command: |
sudo pip install -r requirements/development.txt
- save_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
paths:
- ".venv"
- "/usr/local/bin"
- "/usr/local/lib/python3.6/site-packages"
- run:
command: |
flake8 --max-line-length=125 --exclude=src/kszkepzes,migrations
python src/manage.py migrate
python src/manage.py test
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
destination: tr1
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
[![Build Status](https://travis-ci.org/DevTeamSCH/kszkepzes.svg?branch=master)](https://travis-ci.org/DevTeamSCH/kszkepzes) [![Build Status](https://travis-ci.org/DevTeamSCH/kszkepzes.svg?branch=master)](https://travis-ci.org/DevTeamSCH/kszkepzes)
[![CircleCI](https://circleci.com/gh/DevTeamSCH/kszkepzes/tree/master.svg?style=svg)](https://circleci.com/gh/DevTeamSCH/kszkepzes/tree/master)
## Követelmények ## Követelmények
1. python3.5 1. python3.5
......
Django==1.11.5 Django==2.0.1
djangorestframework==3.6.4 djangorestframework==3.7.7
django-social-authsch==0.1 django-social-authsch==0.1
django-solo==1.1.3
-r base.in -r base.in
flake8==3.4.1 flake8==3.4.1
pip-tools==1.9.0 pip-tools==1.9.0
django-extensions==1.9.1 django-extensions==1.9.9
python-language-server==0.13.0
...@@ -7,25 +7,38 @@ ...@@ -7,25 +7,38 @@
certifi==2017.7.27.1 # via requests certifi==2017.7.27.1 # via requests
chardet==3.0.4 # via requests chardet==3.0.4 # via requests
click==6.7 # via pip-tools click==6.7 # via pip-tools
configparser==3.5.0 # via python-language-server
defusedxml==0.5.0 # via python3-openid, social-auth-core 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-social-authsch==0.1
django==1.11.5 django-solo==1.1.3
djangorestframework==3.6.4 django==2.0.1
djangorestframework==3.7.7
first==2.0.1 # via pip-tools first==2.0.1 # via pip-tools
flake8==3.4.1 flake8==3.4.1
future==0.16.0 # via python-language-server
idna==2.6 # via requests 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 oauthlib==2.0.6 # via requests-oauthlib, social-auth-core
parso==0.1.1 # via jedi
pip-tools==1.9.0 pip-tools==1.9.0
pycodestyle==2.3.1 # via flake8 pluggy==0.6.0 # via python-language-server
pyflakes==1.5.0 # via flake8 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 pyjwt==1.5.3 # via social-auth-core
python-language-server==0.13.0
python3-openid==3.1.0 # via social-auth-core python3-openid==3.1.0 # via social-auth-core
pytz==2017.2 # via django pytz==2017.2 # via django
requests-oauthlib==0.8.0 # via social-auth-core requests-oauthlib==0.8.0 # via social-auth-core
requests==2.18.4 # via requests-oauthlib, 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-app-django==2.0.0 # via django-social-authsch
social-auth-core==1.5.0 # via django-social-authsch, social-auth-app-django 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 urllib3==1.22 # via requests
yapf==0.20.1 # via python-language-server
-r base.in
gunicorn==19.7.1
#
# 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
from django.contrib import admin from django.contrib import admin
from . import models from . import models
from solo.admin import SingletonModelAdmin
@admin.register(models.Profile) @admin.register(models.Profile)
...@@ -14,3 +15,4 @@ class ProfileAdmin(admin.ModelAdmin): ...@@ -14,3 +15,4 @@ class ProfileAdmin(admin.ModelAdmin):
# Register your models here. # Register your models here.
admin.site.register(models.GroupChoice) admin.site.register(models.GroupChoice)
admin.site.register(models.Deadline, SingletonModelAdmin)
from django.core import exceptions
from . import models
def create_profile(backend, user, response, *args, **kwargs):
if backend.name == 'authsch':
try:
user.profile
except exceptions.ObjectDoesNotExist:
models.Profile.objects.create(user=user)
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-01-25 18:42
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0010_auto_20180124_1929'),
]
operations = [
migrations.CreateModel(
name='Deadline',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('deadline', models.DateField()),
],
options={
'abstract': False,
},
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-01-25 18:57
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0011_deadline'),
]
operations = [
migrations.AlterField(
model_name='deadline',
name='deadline',
field=models.DateField(null=True),
),
]
# Generated by Django 2.0.1 on 2018-02-03 19:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0012_auto_20180125_1957'),
]
operations = [
migrations.AlterField(
model_name='profile',
name='join_date',
field=models.DateTimeField(auto_now=True),
),
]
# Generated by Django 2.0.1 on 2018-02-03 19:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0013_auto_20180203_2007'),
]
operations = [
migrations.AlterField(
model_name='deadline',
name='deadline',
field=models.DateTimeField(null=True),
),
]
# Generated by Django 2.0.1 on 2018-02-03 19:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0014_auto_20180203_2010'),
]
operations = [
migrations.AddField(
model_name='profile',
name='updated_at',
field=models.DateTimeField(auto_now=True),
),
migrations.AlterField(
model_name='profile',
name='join_date',
field=models.DateTimeField(auto_now_add=True),
),
]
# Generated by Django 2.0.1 on 2018-02-03 19:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0015_auto_20180203_2014'),
]
operations = [
migrations.AlterField(
model_name='profile',
name='motivation',
field=models.TextField(blank=True, default=''),
),
migrations.AlterField(
model_name='profile',
name='nick',
field=models.CharField(blank=True, default='', max_length=15),
),
]
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from solo.models import SingletonModel
class GroupChoice(models.Model): class GroupChoice(models.Model):
...@@ -18,13 +19,19 @@ class GroupChoice(models.Model): ...@@ -18,13 +19,19 @@ class GroupChoice(models.Model):
class Profile(models.Model): class Profile(models.Model):
join_date = models.DateField(auto_now=True) join_date = models.DateTimeField(auto_now_add=True, editable=False)
updated_at = models.DateTimeField(auto_now=True, editable=False)
user = models.OneToOneField(User, related_name='profile', on_delete=models.CASCADE) user = models.OneToOneField(User, related_name='profile', on_delete=models.CASCADE)
motivation = models.TextField(null=True) # TODO: Change the default to json render side
nick = models.CharField(max_length=15, blank=True, null=True) motivation = models.TextField(blank=True, default='')
nick = models.CharField(max_length=15, blank=True, default='')
signed = models.BooleanField(default=False, null=False) signed = models.BooleanField(default=False, null=False)
groups = models.ManyToManyField(GroupChoice, related_name='profiles') groups = models.ManyToManyField(GroupChoice, related_name='profiles')
# Homeworks=models.ForeignKey(Homework) # Homeworks=models.ForeignKey(Homework)
def __str__(self): def __str__(self):
return self.user.username return self.user.username
class Deadline(SingletonModel):
deadline = models.DateTimeField(null=True)
...@@ -10,7 +10,19 @@ class ChoiceSerializer(serializers.ModelSerializer): ...@@ -10,7 +10,19 @@ class ChoiceSerializer(serializers.ModelSerializer):
class ProfileSerializer(serializers.ModelSerializer): class ProfileSerializer(serializers.ModelSerializer):
groups = serializers.SlugRelatedField(many=True, slug_field="choice", queryset=models.GroupChoice.objects.all()) groups = serializers.SlugRelatedField(many=True, slug_field="choice", queryset=models.GroupChoice.objects.all())
updated_at = serializers.DateTimeField(read_only=True)
signed = serializers.BooleanField()
class Meta: class Meta:
model = models.Profile model = models.Profile
fields = ('id', 'join_date', 'user', 'nick', 'motivation', 'signed', 'groups') fields = ('id', 'join_date', 'updated_at', 'user', 'nick', 'motivation', 'signed', 'groups')
def validate(self, data):
deadline = models.Deadline.get_solo().deadline
if deadline is None:
return data
if data['signed'] is True and data['updated_at'] > deadline:
raise serializers.ValidationError("You cannot join after the deadline")
return data
...@@ -16,6 +16,8 @@ class ProfileViewSet(viewsets.ModelViewSet): ...@@ -16,6 +16,8 @@ class ProfileViewSet(viewsets.ModelViewSet):
if user.has_perm(permissions.IsAdminUser): if user.has_perm(permissions.IsAdminUser):
return models.Profile.objects.all() return models.Profile.objects.all()
return models.Profile.objects.filter(pk=user.profile.id)
@list_route(methods=['get']) @list_route(methods=['get'])
def me(self, request): def me(self, request):
serializer = self.serializer_class(request.user.profile) serializer = self.serializer_class(request.user.profile)
......
...@@ -3,4 +3,4 @@ from . import models ...@@ -3,4 +3,4 @@ from . import models
# Register your models here. # Register your models here.
admin.site.register(models.Solution) admin.site.register(models.Solution)
admin.site.register(models.Task) admin.site.register(models.Task)
\ No newline at end of file
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-01-25 17:17
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 = [
('homework', '0003_auto_20180124_1818'),
]
operations = [
migrations.AlterField(
model_name='solution',
name='created_by',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment