Skip to content

Commit

Permalink
Merge branch 'release/1.5.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
JackMorganNZ committed Jun 9, 2020
2 parents 09feaff + 4f61cf7 commit 807eefd
Show file tree
Hide file tree
Showing 76 changed files with 2,459 additions and 1,075 deletions.
2 changes: 0 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[run]
include = */codewof/*
omit = *migrations*, *tests*
plugins =
django_coverage_plugin
branch = True

[report]
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ install:
jobs:
include:
- stage: test
# script: ./dev ci test_suite
# name: "Run test suite"
script: ./dev ci style
script: ./dev ci test_suite
name: "Run test suite"
- script: ./dev ci style
name: "Run style checker"
- stage: development deployment
script: skip
Expand Down
39 changes: 38 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,52 @@
# Changelog

## 2.0.0

Adds gamification elements (points and achievements) to the website, including for all previous submissions for each user.

- Add gamification system that allows users to earn points and achievements.
- Add ability for the CodeWOF server to recalculate a user's points and achievements from their past attempts.
- Improve the CodeWOF admin site with more information and filtering options.
- Update Django from 2.1.5 to 2.2.3.
- Dependency updates:
- Remove django-coverage-plugin.
- Update coverage from 4.5.4 to 5.1.
- Update django-activeurl from 0.1.12 to 0.2.0.
- Update django-allauth from 0.39.1 to 0.41.0.
- Update django-ckeditor from 5.7.1 to 5.9.0.
- Update django-crispy-forms from 1.7.2 to 1.9.0.
- Update django-debug-toolbar from 2.0 to 2.2.
- Update django-extensions from 2.2.1 to 2.2.9.
- Update django-modeltranslation from 0.13.3 to 0.14.4.
- Update django-model-utils from 3.2.0 to 4.0.0.
- Update django-recaptcha from 2.0.5 to 2.0.6.
- Update django-redis from 4.10.0 to 4.11.0.
- Update django-storages from 1.7.1 to 1.9.1.
- Update google-api-python-client from 1.7.11 to 1.7.12.
- Update google-auth from 1.6.3 to 1.12.0.
- Update google-cloud-logging from 1.12.1 to 1.15.0.
- Update mypy from 0.720 to 0.770.
- Update Pillow from 6.1.0 to 7.0.0.
- Update pydocstyle from 4.0.1 to 5.0.2.
- Update pytest from 5.1.1 to 5.4.1.
- Update pytest-django from 3.5.1 to 3.8.0.
- Update PyYAML from 5.1.2 to 5.3.1.
- Update Sphinx from 2.2.0 to 3.0.4.

## 1.5.3

- Use default settings for split health checks.

## 1.5.2

- Split GCP health check URLs.

## 1.5.1

- Update GCP health checks.

## 1.5.0

- Add 7 new questions.
- Fix test case where no argument was passed for the total of evens question. Fixes #101
- Fix error in example of the driver speed question.
Expand Down Expand Up @@ -37,7 +74,7 @@
- Fix bug where whitespace of user code in attempt wasn't shown in admin interface.
- Fix bug where sender's email address is not listed on contact us forms sent to admin.
- General typo fixes and question clarifications.
- Dependencies changes:
- Dependency updates:
- Update django-recaptcha from 2.0.4 to 2.0.5.
- Update google-api-python-client from 1.7.10 to 1.7.11.
- Update pydocstyle from 4.0.0 to 4.0.1.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This Dockerfile is based off the Google App Engine Python runtime image
# https://github.com/GoogleCloudPlatform/python-runtime
FROM uccser/django:2.1.5
FROM uccser/django:2.2.3

# Add metadata to Docker image
LABEL maintainer="[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-local
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This Dockerfile is based off the Google App Engine Python runtime image
# https://github.com/GoogleCloudPlatform/python-runtime
FROM uccser/django:2.1.5-with-weasyprint
FROM uccser/django:2.2.3-with-weasyprint

# Add metadata to Docker image
LABEL maintainer="[email protected]"
Expand Down
1 change: 1 addition & 0 deletions codewof/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Init file for codeWOF."""
2 changes: 1 addition & 1 deletion codewof/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Configuration for Django system."""

__version__ = "1.5.3"
__version__ = "2.0.0"
__version_info__ = tuple(
[
int(num) if num.isdigit() else num
Expand Down
5 changes: 4 additions & 1 deletion codewof/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import environ
from utils.get_upload_filepath import get_upload_path_for_date


# codewof/codewof/config/settings/base.py - 3 = codewof/codewof/
ROOT_DIR = environ.Path(__file__) - 3

Expand Down Expand Up @@ -316,6 +315,10 @@
'ignore_params': 'no'
}

ACTIVE_URL_CACHE = True
ACTIVE_URL_CACHE_TIMEOUT = 60 * 60 * 24 # 1 day
ACTIVE_URL_CACHE_PREFIX = 'django_activeurl'

# django-rest-framework
# ------------------------------------------------------------------------------
REST_FRAMEWORK = {
Expand Down
4 changes: 3 additions & 1 deletion codewof/config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = False
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = env('DJANGO_SECRET_KEY')
# SECURITY WARNING: App Engine's security features ensure that it is safe to
Expand All @@ -26,7 +28,7 @@

# Exempt Google App Engine cron job URLs from HTTPS to function correctly.
SECURE_REDIRECT_EXEMPT = [
r'^/?cron/.*',
r'^tasks/.*',
]

# DATABASES
Expand Down
30 changes: 25 additions & 5 deletions codewof/general/management/commands/sampledata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@ class Command(management.base.BaseCommand):

help = "Add sample data to database."

def add_arguments(self, parser):
"""Interprets arguments passed to command."""
parser.add_argument(
'--skip_backdate',
action='store_true',
help='skip backdate step',
)

def handle(self, *args, **options):
"""Automatically called when the sampledata command is given."""
if settings.DEPLOYMENT_TYPE == 'prod' and not settings.DEBUG:
raise management.base.CommandError(
'This command can only be executed in DEBUG mode on non-production website.'
)

skip = options['skip_backdate']

# Clear all data
print(LOG_HEADER.format('Wipe database'))
management.call_command('flush', interactive=False)
Expand All @@ -50,7 +60,7 @@ def handle(self, *args, **options):
primary=True,
verified=True
)
print('Admin created.')
print('Admin created.\n')

# Create user account
user = User.objects.create_user(
Expand All @@ -67,18 +77,28 @@ def handle(self, *args, **options):
primary=True,
verified=True
)

UserFactory.create_batch(size=100)
print('Users created.')
print('Users created.\n')

# Codewof
management.call_command('load_questions')
print('Programming questions loaded.')
print('Programming questions loaded.\n')

management.call_command('load_achievements')
print('Achievements loaded.\n')

# Research
StudyFactory.create_batch(size=5)
StudyGroupFactory.create_batch(size=15)
print('Research studies loaded.')
print('Research studies loaded.\n')

# Attempts
AttemptFactory.create_batch(size=50)
print('Attempts loaded.')
print('Attempts loaded.\n')

# Award points and achievements
if not skip:
management.call_command('backdate_points_and_achievements')
else:
print('Ignoring backdate step as requested.\n')
41 changes: 40 additions & 1 deletion codewof/programming/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
QuestionTypeProgram,
QuestionTypeFunction,
QuestionTypeParsons,
QuestionTypeDebugging
QuestionTypeDebugging,
Profile,
Achievement,
Earned,
)

User = get_user_model()
Expand All @@ -23,10 +26,43 @@ class TestCaseAttemptInline(admin.TabularInline):
can_delete = False


class EarnedInline(admin.TabularInline):
"""Configuration to show earned achievements inline within profile admin."""

model = Earned
extra = 1


class ProfileAdmin(admin.ModelAdmin):
"""Configuration for displaying profiles in admin."""

list_display = ('user', 'points', 'goal', 'has_backdated')
list_filter = ['goal', 'has_backdated']
ordering = ('user', )
inlines = (EarnedInline, )


class AchievementAdmin(admin.ModelAdmin):
"""Configuration for displaying achievements in admin."""

list_display = ('id_name', 'display_name', 'achievement_tier')
list_filter = ['achievement_tier']
ordering = ('id_name', )


class EarnedAdmin(admin.ModelAdmin):
"""Configuration for displaying earned achievements in admin."""

list_display = ('date', 'achievement', 'profile')
list_filter = ['achievement']
ordering = ('-date', )


class AttemptAdmin(admin.ModelAdmin):
"""Configuration for displaying attempts in admin."""

list_display = ('datetime', 'question', 'profile', 'passed_tests')
list_filter = ['passed_tests', 'question']
ordering = ('-datetime', )
inlines = (TestCaseAttemptInline, )

Expand All @@ -43,3 +79,6 @@ class Media:
admin.site.register(QuestionTypeFunction)
admin.site.register(QuestionTypeParsons)
admin.site.register(QuestionTypeDebugging)
admin.site.register(Profile, ProfileAdmin)
admin.site.register(Achievement, AchievementAdmin)
admin.site.register(Earned, EarnedAdmin)
Loading

0 comments on commit 807eefd

Please sign in to comment.