diff --git a/bosm/__pycache__/__init__.cpython-36.pyc b/bosm/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..792f051 Binary files /dev/null and b/bosm/__pycache__/__init__.cpython-36.pyc differ diff --git a/bosm/__pycache__/settings.cpython-36.pyc b/bosm/__pycache__/settings.cpython-36.pyc new file mode 100644 index 0000000..4dc2043 Binary files /dev/null and b/bosm/__pycache__/settings.cpython-36.pyc differ diff --git a/bosm/__pycache__/urls.cpython-36.pyc b/bosm/__pycache__/urls.cpython-36.pyc new file mode 100644 index 0000000..410ddb4 Binary files /dev/null and b/bosm/__pycache__/urls.cpython-36.pyc differ diff --git a/bosm/__pycache__/wsgi.cpython-36.pyc b/bosm/__pycache__/wsgi.cpython-36.pyc new file mode 100644 index 0000000..600c2f2 Binary files /dev/null and b/bosm/__pycache__/wsgi.cpython-36.pyc differ diff --git a/bosm/settings.py b/bosm/settings.py index 95107ac..2db126f 100644 --- a/bosm/settings.py +++ b/bosm/settings.py @@ -25,7 +25,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ['abhishekspeer.pythonanywhere.com', '127.0.0.1', 'localhost',] +ALLOWED_HOSTS = ['abhishekspeer.pythonanywhere.com', '127.0.0.1', 'localhost', ] # Application definition @@ -145,7 +145,7 @@ LOGIN_REDIRECT_URL = 'main' LOGOUT_REDIRECT_URL = 'main' -SOCIAL_AUTH_GOOGLE_OAUTH2_KEY ='1060438488864-oqbnppt4fbd4ml7fu6d6l6u51m14k60f.apps.googleusercontent.com' +SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '1060438488864-oqbnppt4fbd4ml7fu6d6l6u51m14k60f.apps.googleusercontent.com' SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'qFZH7K_i_8C2xaqsLwsDXi_1' STATICFILES_DIRS = [ diff --git a/db.sqlite3 b/db.sqlite3 index 71a8671..047cb2e 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/sportzilla/__pycache__/__init__.cpython-36.pyc b/sportzilla/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..c83bc0e Binary files /dev/null and b/sportzilla/__pycache__/__init__.cpython-36.pyc differ diff --git a/sportzilla/__pycache__/admin.cpython-36.pyc b/sportzilla/__pycache__/admin.cpython-36.pyc new file mode 100644 index 0000000..a91b273 Binary files /dev/null and b/sportzilla/__pycache__/admin.cpython-36.pyc differ diff --git a/sportzilla/__pycache__/apps.cpython-36.pyc b/sportzilla/__pycache__/apps.cpython-36.pyc new file mode 100644 index 0000000..0b20b2c Binary files /dev/null and b/sportzilla/__pycache__/apps.cpython-36.pyc differ diff --git a/sportzilla/__pycache__/models.cpython-36.pyc b/sportzilla/__pycache__/models.cpython-36.pyc new file mode 100644 index 0000000..9392d22 Binary files /dev/null and b/sportzilla/__pycache__/models.cpython-36.pyc differ diff --git a/sportzilla/__pycache__/signals.cpython-36.pyc b/sportzilla/__pycache__/signals.cpython-36.pyc new file mode 100644 index 0000000..e2acac7 Binary files /dev/null and b/sportzilla/__pycache__/signals.cpython-36.pyc differ diff --git a/sportzilla/__pycache__/urls.cpython-36.pyc b/sportzilla/__pycache__/urls.cpython-36.pyc new file mode 100644 index 0000000..97fab48 Binary files /dev/null and b/sportzilla/__pycache__/urls.cpython-36.pyc differ diff --git a/sportzilla/__pycache__/views.cpython-36.pyc b/sportzilla/__pycache__/views.cpython-36.pyc new file mode 100644 index 0000000..5ffc0b7 Binary files /dev/null and b/sportzilla/__pycache__/views.cpython-36.pyc differ diff --git a/sportzilla/apps.py b/sportzilla/apps.py index feff336..a3e5bcf 100644 --- a/sportzilla/apps.py +++ b/sportzilla/apps.py @@ -3,3 +3,6 @@ class SportzillaConfig(AppConfig): name = 'sportzilla' + + def ready(self): + import sportzilla.signals diff --git a/sportzilla/migrations/0001_initial.py b/sportzilla/migrations/0001_initial.py new file mode 100644 index 0000000..3e4f1f1 --- /dev/null +++ b/sportzilla/migrations/0001_initial.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2019-03-23 10:09 +from __future__ import unicode_literals + +import django.contrib.auth.models +import django.contrib.auth.validators +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0008_alter_user_username_max_length'), + ] + + operations = [ + migrations.CreateModel( + name='CustomUser', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), + ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=30, verbose_name='last name')), + ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), + ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('score', models.IntegerField(default=0)), + ('rank', models.IntegerField(blank=True, null=True)), + ('question_no1', models.IntegerField(default=1)), + ('question_no2', models.IntegerField(default=1)), + ('question_no3', models.IntegerField(default=1)), + ('question_no4', models.IntegerField(default=1)), + ('question_no5', models.IntegerField(default=1)), + ('answers_given', models.CharField(default='0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', max_length=200)), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), + ], + options={ + 'verbose_name': 'user', + 'verbose_name_plural': 'users', + 'abstract': False, + }, + managers=[ + ('objects', django.contrib.auth.models.UserManager()), + ], + ), + migrations.CreateModel( + name='Question', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('question_no', models.IntegerField()), + ('solution', models.CharField(max_length=50)), + ('marks', models.IntegerField(null=True)), + ('question_img', models.ImageField(blank=True, upload_to='')), + ('question', models.CharField(default='', max_length=10000)), + ('question_type', models.CharField(default='', max_length=100)), + ], + ), + ] diff --git a/sportzilla/migrations/0002_customuser_login_count.py b/sportzilla/migrations/0002_customuser_login_count.py new file mode 100644 index 0000000..0c025bc --- /dev/null +++ b/sportzilla/migrations/0002_customuser_login_count.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2019-03-23 10:31 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sportzilla', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='customuser', + name='login_count', + field=models.IntegerField(default=0), + ), + ] diff --git a/sportzilla/migrations/__init__.py b/sportzilla/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sportzilla/migrations/__pycache__/0001_initial.cpython-36.pyc b/sportzilla/migrations/__pycache__/0001_initial.cpython-36.pyc new file mode 100644 index 0000000..18a2cd0 Binary files /dev/null and b/sportzilla/migrations/__pycache__/0001_initial.cpython-36.pyc differ diff --git a/sportzilla/migrations/__pycache__/0002_customuser_login_count.cpython-36.pyc b/sportzilla/migrations/__pycache__/0002_customuser_login_count.cpython-36.pyc new file mode 100644 index 0000000..c94ac89 Binary files /dev/null and b/sportzilla/migrations/__pycache__/0002_customuser_login_count.cpython-36.pyc differ diff --git a/sportzilla/migrations/__pycache__/__init__.cpython-36.pyc b/sportzilla/migrations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000..a971015 Binary files /dev/null and b/sportzilla/migrations/__pycache__/__init__.cpython-36.pyc differ diff --git a/sportzilla/models.py b/sportzilla/models.py index b269524..676c1e6 100644 --- a/sportzilla/models.py +++ b/sportzilla/models.py @@ -10,18 +10,21 @@ class CustomUser(AbstractUser): question_no3 = models.IntegerField(default=1) question_no4 = models.IntegerField(default=1) question_no5 = models.IntegerField(default=1) - answers_given = models.CharField(max_length=200, default="0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") + login_count = models.IntegerField(default=0) + answers_given = models.CharField( + max_length=200, default="0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") def __str__(self): return self.username + class Question(models.Model): question_no = models.IntegerField() solution = models.CharField(max_length=50) marks = models.IntegerField(null=True) question_img = models.ImageField(blank=True) - question = models.CharField(max_length=10000,default="") - question_type = models.CharField(max_length=100,default="") + question = models.CharField(max_length=10000, default="") + question_type = models.CharField(max_length=100, default="") def __str__(self): - return str(self.question_no)+self.question_type #+ ' : ' + self.answer \ No newline at end of file + return str(self.question_no)+self.question_type # + ' : ' + self.answer diff --git a/sportzilla/signals.py b/sportzilla/signals.py new file mode 100644 index 0000000..813298f --- /dev/null +++ b/sportzilla/signals.py @@ -0,0 +1,14 @@ +from .models import CustomUser +from django.contrib.auth.models import User +from django.dispatch import receiver +from django.contrib.auth import logout +from django.contrib.auth.signals import user_logged_in + + +@receiver(user_logged_in, sender=CustomUser) +def login_check(sender, request, user, **kwargs): + user.login_count += 1 + print('logged in') + user.save() + if user.login_count > 1: + logout(request)