Skip to content

Commit

Permalink
feat(delete-activate-trainer)Enable deletion/deactivation of trainers

Browse files Browse the repository at this point in the history
This commit allows managers to delete and deactivate trainers previously managers
are unable to remove or deactivate trainers added by the admin,
this new feature allows managers to delete/deactivate trainers giving them control over the system



[Delivers #157731627]
  • Loading branch information
hariclerry committed Jun 13, 2018
1 parent 1cdc7ea commit a25fe7b
Show file tree
Hide file tree
Showing 32 changed files with 517 additions and 30 deletions.
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ whitenoise
gunicorn
dj-database-url==0.4.2
dj-static==0.0.6
autopep8
flake8
psycopg2-binary


# REST API
djangorestframework>=3.2,<3.3
Expand All @@ -34,6 +38,3 @@ django-cors-headers

# Python3 compatibility
six
autopep8
flake8
psycopg2-binary
6 changes: 3 additions & 3 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('WG_NAME') or "test_wger",
'NAME': os.environ.get('WG_NAME') or "wg",
'USER': os.environ.get('WG_USER') or 'postgres',
'HOST': os.environ.get('WG_HOST') or 'localhost',
'PASSWORD': os.environ.get('WG_PASSWORD') or '',
'PORT': os.environ.get('WG_PORT') or '',
'PASSWORD': os.environ.get('WG_PASSWORD') or 'clerry',
'PORT': os.environ.get('WG_PORT') or '5432',
}
}

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ ignore = W503

# Flake8 configuration settings
[flake8]
exclude = .git,__pycache__,urls.py,tasks.py,generator.py,*migrations*,*bower_components*,*docs*,__*__,
exclude = .git,__pycache__,urls.py,tasks.py,settings.py,generator.py,*migrations*,*bower_components*,*docs*,__*__,
max-line-length = 100
ignore = F401,W503
Binary file modified wger/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion wger/config/tests/test_gym_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ def test_update_userprofile(self):
self.assertEqual(UserProfile.objects.filter(gym=gym).count(), 24)

# 13 non-managers
self.assertEqual(GymUserConfig.objects.filter(gym=gym).count(), 13)
self.assertEqual(GymUserConfig.objects.filter(gym=gym).count(), 18)
24 changes: 24 additions & 0 deletions wger/core/fixtures/test-user-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 1,
Expand Down Expand Up @@ -511,6 +512,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 2,
Expand Down Expand Up @@ -542,6 +544,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": true,
"is_activated": false,
"show_comments": false,
"show_english_ingredients": false,
"user": 3,
Expand Down Expand Up @@ -571,6 +574,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 4,
Expand Down Expand Up @@ -602,6 +606,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 5,
Expand Down Expand Up @@ -633,6 +638,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 6,
Expand Down Expand Up @@ -664,6 +670,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 7,
Expand Down Expand Up @@ -695,6 +702,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 8,
Expand Down Expand Up @@ -726,6 +734,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 9,
Expand Down Expand Up @@ -757,6 +766,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 10,
Expand Down Expand Up @@ -788,6 +798,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 11,
Expand Down Expand Up @@ -819,6 +830,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 12,
Expand Down Expand Up @@ -850,6 +862,7 @@
"model": "core.userprofile",
"fields": {
"is_temporary": false,
"is_activated": true,
"show_comments": false,
"show_english_ingredients": false,
"user": 13,
Expand Down Expand Up @@ -881,6 +894,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -912,6 +926,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -943,6 +958,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -974,6 +990,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -1005,6 +1022,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -1036,6 +1054,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -1067,6 +1086,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -1098,6 +1118,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -1129,6 +1150,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -1160,6 +1182,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down Expand Up @@ -1191,6 +1214,7 @@
"model": "core.userprofile",
"fields": {
"workout_reminder": 20,
"is_activated": true,
"height": 180,
"show_english_ingredients": false,
"show_comments": false,
Expand Down
3 changes: 2 additions & 1 deletion wger/core/fixtures/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"show_comments": false,
"show_english_ingredients": false,
"user": 1,
"gym": 1
"gym": 1,
"is_activated": true
}
},
{
Expand Down
20 changes: 20 additions & 0 deletions wger/core/migrations/0012_userprofile_trainer_active.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-06-09 14:19
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0011_merge'),
]

operations = [
migrations.AddField(
model_name='userprofile',
name='trainer_active',
field=models.BooleanField(default=True, verbose_name='Shows status of Gym members'),
),
]
19 changes: 19 additions & 0 deletions wger/core/migrations/0013_remove_userprofile_trainer_active.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-06-09 14:50
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0012_userprofile_trainer_active'),
]

operations = [
migrations.RemoveField(
model_name='userprofile',
name='trainer_active',
),
]
20 changes: 20 additions & 0 deletions wger/core/migrations/0014_userprofile_is_activated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-06-11 08:19
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0013_remove_userprofile_trainer_active'),
]

operations = [
migrations.AddField(
model_name='userprofile',
name='is_activated',
field=models.BooleanField(default=True, verbose_name='Shows status of Gym members'),
),
]
2 changes: 2 additions & 0 deletions wger/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class UserProfile(models.Model):
Flag to mark a temporary user (demo account)
'''

is_activated = models.BooleanField(verbose_name=_('Shows status of Gym members'),
default=True)
#
# User preferences
#
Expand Down
2 changes: 1 addition & 1 deletion wger/core/templates/base_wide.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h2 id="page-title" class="page-header">
<div class="col-sm-12" id="main-content">
{% if messages and not no_messages %}
{% for message in messages %}
<div class="alert {% if message.tags == 'warning'%}alert-error{% elif message.tags == 'info' %}alert-info{% elif message.tags == 'success' %}alert-success{% endif %}">
<div class="alert {% if message.tags == 'warning'%}alert-error{% elif message.tags == 'info' %}alert-info{% elif message.tags == 'success' %}alert-success{% elif 'danger' in message.tags %}alert-danger{% endif %}">
<a href="#" class="close extra-bold" data-dismiss="alert">&times;</a>
{{message}}
</div>
Expand Down
9 changes: 9 additions & 0 deletions wger/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@
url(r'^(?P<user_pk>\d+)/delete$',
user.delete,
name='delete'),
url(r'^(?P<user_pk>\d+)/(?P<gym_pk>\d+)/delete_trainer$',
user.delete_trainer_from_gym,
name='delete_trainer'),
url(r'^(?P<user_pk>\d+)/(?P<gym_pk>\d+)/deactivate_trainer',
user.deactivate_trainer,
name='deactivate_trainer'),
url(r'^(?P<user_pk>\d+)/(?P<gym_pk>\d+)/activate_trainer',
user.activate_trainer,
name='activate_trainer'),
url(r'^(?P<user_pk>\d+)/trainer-login$',
user.trainer_login,
name='trainer-login'),
Expand Down
Loading

0 comments on commit a25fe7b

Please sign in to comment.