diff --git a/accounts/admin.py b/accounts/admin.py index 59bd3dde..ef3cdd1b 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -3,7 +3,7 @@ from django.contrib.auth.forms import UserChangeForm, UserCreationForm from django.contrib.auth.decorators import login_required -from .models import CustomUser, Organisation, EmailTemplate +from .models import CustomUser, Organisation, EmailTemplate, Status from accounts.models import SlackSiteSettings @@ -13,7 +13,7 @@ class CustomUserAdmin(BaseUserAdmin): ('Personal info', {'fields': ( 'username', 'first_name', 'last_name', 'full_name', 'slack_display_name', - 'current_lms_module', 'organisation', + 'status', 'organisation', 'timezone', 'user_type', 'is_external')}), ('Permissions', {'fields': ( 'is_active', 'is_staff', 'is_superuser', @@ -40,7 +40,7 @@ class CustomUserAdmin(BaseUserAdmin): form = UserChangeForm add_form = UserCreationForm list_display = ('email', 'username', 'full_name', 'is_superuser', 'user_type', - 'is_external') + 'is_external', 'status') list_filter = ('is_staff', 'is_superuser', 'is_active', 'groups', 'is_external') search_fields = ('full_name', 'email', 'slack_display_name') @@ -59,3 +59,5 @@ class EmailTemplateAdmin(admin.ModelAdmin): admin.site.register(Organisation) admin.site.register(SlackSiteSettings) admin.site.register(EmailTemplate, EmailTemplateAdmin) +admin.site.register(Status) + diff --git a/accounts/decorators.py b/accounts/decorators.py index 848ede17..58e79875 100644 --- a/accounts/decorators.py +++ b/accounts/decorators.py @@ -42,7 +42,7 @@ def wrapped_view(request, *args, **kwargs): and hackathon.organisation.id != request.user.organisation.id and hackathon.is_public is False): messages.error(request, 'You cannot access this page.') - return redirect(reverse('hackathon:hackathon-list')) + return redirect(reverse('hackathon:list-hackathons')) return view_function(request, *args, **kwargs) @@ -62,13 +62,13 @@ def wrapped_view(request, *args, **kwargs): team = get_object_or_404(HackTeam, id=team_id) if not team.hackathon: messages.error(request, 'You cannot access this page.') - return redirect(reverse('hackathon:hackathon-list')) + return redirect(reverse('hackathon:list-hackathons')) if (team.hackathon.organisation.id != 1 and team.hackathon.organisation.id != request.user.organisation.id and team.hackathon.is_public is False): messages.error(request, 'You cannot access this page.') - return redirect(reverse('hackathon:hackathon-list')) + return redirect(reverse('hackathon:list-hackathons')) return view_function(request, *args, **kwargs) diff --git a/accounts/fixtures/accounts.json b/accounts/fixtures/accounts.json index 4248b408..0d50a9bd 100644 --- a/accounts/fixtures/accounts.json +++ b/accounts/fixtures/accounts.json @@ -1,24 +1,10 @@ [ - { - "model": "accounts.organisation", - "pk": 1, - "fields": { - "display_name": "Code Institute" - } - }, - { - "model": "accounts.organisation", - "pk": 2, - "fields": { - "display_name": "Example Partner" - } - }, { "model": "accounts.customuser", "pk": 1, "fields": { "password": "pbkdf2_sha256$216000$oJBkGfTkbf4f$xAa9o8KpGfXz5Dh8pG/tI3O6IT381qRPt0WPHN2KuRU=", - "last_login": "2021-01-18T11:37:31.438Z", + "last_login": "2021-10-11T19:58:11.472Z", "is_superuser": true, "username": "admin@example.com", "first_name": "Admin", @@ -29,13 +15,14 @@ "date_joined": "2020-10-26T16:54:30.184Z", "full_name": "Admin User", "slack_display_name": "admin_ci", - "current_lms_module": "staff", + "status": 11, "organisation": 1, "about": "This is a pre-seeded admin account for development.", "website_url": "http://www.example.com", "profile_image": "", "profile_is_public": true, "email_is_public": true, + "is_external": false, "groups": [], "user_permissions": [] } @@ -54,15 +41,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T21:39:10.940Z", - "full_name": "Luke Skywalker", + "full_name": "", "slack_display_name": "Luke_Skywalker", - "current_lms_module": "programme_preliminaries", + "status": 1, "organisation": 1, - "about": "Enthusiastic front-end developer with a passion for React and Angular.", - "website_url": "http://www.luke-skywalker.xwing", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, + "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -81,15 +69,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T21:43:53.334Z", - "full_name": "C-3PO", + "full_name": "", "slack_display_name": "C-3PO", - "current_lms_module": "alumni", + "status": 7, "organisation": 1, - "about": "Interested in general robotics and looking for other developers to work with on projects. Main tech stack is Python", - "website_url": "http://www.c3po.com", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, - "email_is_public": true, + "profile_is_public": false, + "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -108,15 +97,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T21:45:59.264Z", - "full_name": "R2 D2", + "full_name": "", "slack_display_name": "R2-D2", - "current_lms_module": "python_essentials", + "status": 4, "organisation": 1, - "about": "Interested in general robotics and looking for other developers to work with on projects. Main tech stack is Python", - "website_url": "http://www.r2-d2.gov.org", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, - "email_is_public": true, + "profile_is_public": false, + "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -135,15 +125,16 @@ "is_staff": true, "is_active": true, "date_joined": "2020-10-26T21:48:44.064Z", - "full_name": "Darth Vader", + "full_name": "", "slack_display_name": "Darth_Vader", - "current_lms_module": "staff", + "status": 11, "organisation": 1, - "about": "Coder with multiple years of experience in front- and backend.", - "website_url": "http://www.darth-vader.eu", + "about": "", + "website_url": "", "profile_image": "", "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -162,15 +153,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T21:53:11.458Z", - "full_name": "Leia Organa", + "full_name": "", "slack_display_name": "Leia_Organa", - "current_lms_module": "javascript_essentials", + "status": 3, "organisation": 1, - "about": "Tech evangelist with a wide range of skills. Hoping for a new challenge to do with ML.", - "website_url": "http://www.leiaorgana.com", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, - "email_is_public": true, + "profile_is_public": false, + "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -189,15 +181,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T21:54:54.941Z", - "full_name": "Owen Lars", + "full_name": "", "slack_display_name": "Owen_Lars", - "current_lms_module": "html_essentials", + "status": 1, "organisation": 1, - "about": "Not too much to say about me...I like coding and developing apps.", - "website_url": "http://www.ownerlars.com", + "about": "", + "website_url": "", "profile_image": "", "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -216,15 +209,16 @@ "is_staff": true, "is_active": true, "date_joined": "2020-10-26T21:57:45.272Z", - "full_name": "Obi-Wan Kenobi", + "full_name": "", "slack_display_name": "Obi-Wan_Kenobi", - "current_lms_module": "staff", + "status": 11, "organisation": 1, - "about": "I have more than 10 years experiencing in developing and deploying enterprise scale applications.", - "website_url": "http://www.obi-wan.kenobig.org", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, - "email_is_public": true, + "profile_is_public": false, + "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -243,15 +237,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T22:00:34.989Z", - "full_name": "Anakin Skywalker", + "full_name": "", "slack_display_name": "Anakin_Skywalker", - "current_lms_module": "programming_paradigms", + "status": 1, "organisation": 1, - "about": "Just started programming, but I really like it and am trying to get more and more into it. Looking forward to deploying my first website!!", + "about": "", "website_url": "", "profile_image": "", - "profile_is_public": true, + "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -270,15 +265,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T22:02:30.940Z", - "full_name": "Chewbacca", + "full_name": "", "slack_display_name": "Chewbacca", - "current_lms_module": "css_essentials", + "status": 1, "organisation": 1, - "about": "HERRNNNGGGHHHHH!!!", - "website_url": "http://www.chew.ie", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, + "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -297,15 +293,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T22:04:02.107Z", - "full_name": "Han Solo", + "full_name": "", "slack_display_name": "Han_Solo", - "current_lms_module": "data_centric_development", + "status": 4, "organisation": 1, - "about": "Experienced developer; mainly working on shipping applications to production servers. Linux expert!", - "website_url": "http://www.han.solo", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, - "email_is_public": true, + "profile_is_public": false, + "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -324,15 +321,16 @@ "is_staff": true, "is_active": true, "date_joined": "2020-10-26T22:05:58.558Z", - "full_name": "Yoda", + "full_name": "", "slack_display_name": "Yoda", - "current_lms_module": "staff", + "status": 11, "organisation": 1, - "about": "Experienced DevOps specialist with about 5 years of web application development as well.", - "website_url": "http://www.yoda.com", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, + "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -351,15 +349,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T22:08:52.279Z", - "full_name": "Senator Palpatine", + "full_name": "", "slack_display_name": "Palpatine", - "current_lms_module": "full_stack_frameworks_with_django", + "status": 5, "organisation": 1, "about": "", "website_url": "", "profile_image": "", "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -380,13 +379,14 @@ "date_joined": "2020-10-26T22:10:28.037Z", "full_name": "Boba Fett", "slack_display_name": "Boba_Fett", - "current_lms_module": "python_essentials", + "status": 4, "organisation": 1, - "about": "Django is my passion, but Flask is okay too. Not much interested in Frontend.", - "website_url": "http://www.bobafett.com", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, + "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -405,15 +405,16 @@ "is_staff": true, "is_active": true, "date_joined": "2020-10-26T22:13:13.056Z", - "full_name": "Qui-Gon Jinn", + "full_name": "", "slack_display_name": "Qui-Gon_Jinn", - "current_lms_module": "staff", + "status": 11, "organisation": 1, "about": "", - "website_url": "http://www.quigonjin.com", + "website_url": "", "profile_image": "", "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -432,15 +433,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T22:16:45.860Z", - "full_name": "Padme Amidala", + "full_name": "", "slack_display_name": "Padme_Amidala", - "current_lms_module": "interactive_frontend_development", + "status": 3, "organisation": 1, - "about": "I am an aspiring junior developer with interest in Data Analytics as well.", - "website_url": "http://www.padmeamidala.com", + "about": "", + "website_url": "", "profile_image": "", "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -459,15 +461,16 @@ "is_staff": true, "is_active": true, "date_joined": "2020-10-26T22:20:27.772Z", - "full_name": "Mace Windu", + "full_name": "", "slack_display_name": "Mace_Windu", - "current_lms_module": "staff", + "status": 11, "organisation": 1, - "about": "I have more than 10 years experience in web application development with Java. Trying to upskill and learn Python/Django.", - "website_url": "http://www.macewindu.com", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, - "email_is_public": true, + "profile_is_public": false, + "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -486,15 +489,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T22:22:47.130Z", - "full_name": "Count Dooku", + "full_name": "", "slack_display_name": "Dooku", - "current_lms_module": "user_centric_frontend_development", + "status": 1, "organisation": 1, - "about": "Just starting out to learn programming. Really enjoying Bootstrap and working on my website.", - "website_url": "http://www.dooku.it", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, - "email_is_public": true, + "profile_is_public": false, + "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -513,15 +517,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T22:25:11.784Z", - "full_name": "Jango Fett", + "full_name": "", "slack_display_name": "Jango_Fett", - "current_lms_module": "interactive_frontend_development", + "status": 3, "organisation": 1, "about": "", "website_url": "", "profile_image": "", "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -540,15 +545,16 @@ "is_staff": false, "is_active": true, "date_joined": "2020-10-26T22:28:36.422Z", - "full_name": "Shmi Skywalker", + "full_name": "", "slack_display_name": "Shmi_Skywalker", - "current_lms_module": "practical_python", + "status": 4, "organisation": 1, - "about": "Very experienced Software Developer mainly in the enterprise sector working on HR solutions.", - "website_url": "http://www.shmi-skywalker.com", + "about": "", + "website_url": "", "profile_image": "", - "profile_is_public": true, - "email_is_public": true, + "profile_is_public": false, + "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } @@ -569,15 +575,16 @@ "date_joined": "2021-01-18T21:18:08.530Z", "full_name": "Admin User 2", "slack_display_name": "admin2_ci", - "current_lms_module": "staff", + "status": 11, "organisation": 1, "about": "", "website_url": "", "profile_image": "", "profile_is_public": false, "email_is_public": false, + "is_external": false, "groups": [], "user_permissions": [] } } -] +] \ No newline at end of file diff --git a/accounts/fixtures/organisation.json b/accounts/fixtures/organisation.json index 5efeba3b..300ac9ae 100644 --- a/accounts/fixtures/organisation.json +++ b/accounts/fixtures/organisation.json @@ -5,5 +5,12 @@ "fields": { "display_name": "Code Institute" } - } + }, + { + "model": "accounts.organisation", + "pk": 2, + "fields": { + "display_name": "Example Partner" + } + } ] diff --git a/accounts/fixtures/profiles.json b/accounts/fixtures/profiles.json deleted file mode 100644 index ff45db30..00000000 --- a/accounts/fixtures/profiles.json +++ /dev/null @@ -1,477 +0,0 @@ -[ - { - "model":"accounts.customuser", - "pk":2, - "fields":{ - "password":"pbkdf2_sha256$216000$kBiMuaU8mw6v$ysaYm7kaEKUcAzExXKDennzKYz9JkbKUeeHab1tnLyo=", - "last_login":null, - "is_superuser":false, - "username":"luke.skywalker@test.com", - "first_name":"Luke", - "last_name":"Skywalker", - "email":"luke.skywalker@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T21:39:10.940Z", - "slack_display_name":"Luke_Skywalker", - "current_lms_module":"programme_preliminaries", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":3, - "fields":{ - "password":"pbkdf2_sha256$216000$ZfCHSHlqCJrK$9uaLBqv4DRRQEd372YgCRIlIBNMXLXF/75VeOcsuB2s=", - "last_login":null, - "is_superuser":false, - "username":"C-3PO@test.com", - "first_name":"C", - "last_name":"3PO", - "email":"C-3PO@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T21:43:53.334Z", - "slack_display_name":"C-3PO", - "current_lms_module":"alumni", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":4, - "fields":{ - "password":"pbkdf2_sha256$216000$o7pKD26GEmED$FKBn5gURK75GQOCJ9KeqdymD/P1vPAU+k30GHQ46LpU=", - "last_login":null, - "is_superuser":false, - "username":"R2-D2@test.com", - "first_name":"R2", - "last_name":"D2", - "email":"R2-D2@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T21:45:59.264Z", - "slack_display_name":"R2-D2", - "current_lms_module":"python_essentials", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":5, - "fields":{ - "password":"pbkdf2_sha256$216000$txXDbshpnZPQ$Q1Lv39MHn3ajbMLMTw7Mfsa19zK8xAGadXuNlVXV5E0=", - "last_login":null, - "is_superuser":false, - "username":"Darth.Vader@test.com", - "first_name":"Darth", - "last_name":"Vader", - "email":"Darth.Vader@test.com", - "is_staff":true, - "is_active":true, - "date_joined":"2020-10-26T21:48:44.064Z", - "slack_display_name":"Darth_Vader", - "current_lms_module":"staff", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":6, - "fields":{ - "password":"pbkdf2_sha256$216000$2ja8HDA1G1Jy$xFp5WL5QzFw/7UYT8Kh58x1/6Zu0+58mDCGasjzYnCI=", - "last_login":null, - "is_superuser":false, - "username":"Leia.Organa@test.com", - "first_name":"Leia", - "last_name":"Organa", - "email":"Leia.Organa@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T21:53:11.458Z", - "slack_display_name":"Leia_Organa", - "current_lms_module":"javascript_essentials", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":7, - "fields":{ - "password":"pbkdf2_sha256$216000$Z1JbqdpOHLlY$JR2ITv85Va1ltv9n2ll/B0zPKEnKx0DehinYhjAAaF8=", - "last_login":null, - "is_superuser":false, - "username":"Owen.Lars@test.com", - "first_name":"Owen", - "last_name":"Lars", - "email":"Owen.Lars@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T21:54:54.941Z", - "slack_display_name":"Owen_Lars", - "current_lms_module":"html_essentials", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":8, - "fields":{ - "password":"pbkdf2_sha256$216000$Vk8Y0KNIJGIm$4Z0eEDrUp82XTW87kmD6BhMvw2he3aq8t4sOFK+HV1k=", - "last_login":null, - "is_superuser":false, - "username":"Obi-Wan.Kenobi@test.com", - "first_name":"Obi-Wan", - "last_name":"Kenobi", - "email":"Obi-Wan.Kenobi@test.com", - "is_staff":true, - "is_active":true, - "date_joined":"2020-10-26T21:57:45.272Z", - "slack_display_name":"Obi-Wan_Kenobi", - "current_lms_module":"staff", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":9, - "fields":{ - "password":"pbkdf2_sha256$216000$yz1ZRQFnCoXI$jioZFjK5Z1xv0qc3Oo4k+7tRZQ+2Z8YWgmAmWTafDqU=", - "last_login":null, - "is_superuser":false, - "username":"Anakin.Skywalker@test.com", - "first_name":"Anakin", - "last_name":"Skywalker", - "email":"Anakin.Skywalker@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T22:00:34.989Z", - "slack_display_name":"Anakin_Skywalker", - "current_lms_module":"programming_paradigms", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":10, - "fields":{ - "password":"pbkdf2_sha256$216000$NvJg7DSh7LSq$SQTCUAxcdvedXXS/aH1zsFSPdi8Nk9EywTm34jMgcpo=", - "last_login":null, - "is_superuser":false, - "username":"Chewbacca@test.com", - "first_name":"Chewbacca", - "last_name":"Chewbacca", - "email":"Chewbacca@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T22:02:30.940Z", - "slack_display_name":"Chewbacca", - "current_lms_module":"css_essentials", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":11, - "fields":{ - "password":"pbkdf2_sha256$216000$t0cBUaxPu8gw$y5KYlfoQOQFSgPAyTJpr8Mi5e7TGWurCnUasc6r0wc4=", - "last_login":null, - "is_superuser":false, - "username":"Han.Solo@test.com", - "first_name":"Han", - "last_name":"Solo", - "email":"Han.Solo@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T22:04:02.107Z", - "slack_display_name":"Han_Solo", - "current_lms_module":"data_centric_development", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":12, - "fields":{ - "password":"pbkdf2_sha256$216000$9C7D4HKDJdJf$v7SnGYCENGmaZTOlu6OAnrD1nUp7BmH+5S49zCb/JBc=", - "last_login":null, - "is_superuser":true, - "username":"Yoda@test.com", - "first_name":"Yoda", - "last_name":"Yoda", - "email":"Yoda@test.com", - "is_staff":true, - "is_active":true, - "date_joined":"2020-10-26T22:05:58.558Z", - "slack_display_name":"Yoda", - "current_lms_module":"staff", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":13, - "fields":{ - "password":"pbkdf2_sha256$216000$sgDJ4gSlYGJN$9cQFoWvTVxTsFOwsw7bzRzWMZYRKV+Qy4sX3FJWcF7Q=", - "last_login":null, - "is_superuser":false, - "username":"Palpatine@test.com", - "first_name":"Palpatine", - "last_name":"Palpatine", - "email":"Palpatine@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T22:08:52.279Z", - "slack_display_name":"Palpatine", - "current_lms_module":"full_stack_frameworks_with_django", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":14, - "fields":{ - "password":"pbkdf2_sha256$216000$oPSBeHtl3g5I$QzCEx/tEa8VcXrttEIef3K7EudRj6Zy03+KORNAMfy0=", - "last_login":null, - "is_superuser":false, - "username":"Boba.Fett@test.com", - "first_name":"Boba", - "last_name":"Fett", - "email":"Boba.Fett@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T22:10:28.037Z", - "slack_display_name":"Boba_Fett", - "current_lms_module":"python_essentials", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":15, - "fields":{ - "password":"pbkdf2_sha256$216000$CgM2TEIRLcdO$Mx2i0hkL9SaIEOGTmMo0fnHAV3QbSG7exPXwq16+6Hk=", - "last_login":null, - "is_superuser":false, - "username":"Qui-Gon.Jinn@test.com", - "first_name":"Qui-Gon", - "last_name":"Jinn", - "email":"Qui-Gon.Jinn@test.com", - "is_staff":true, - "is_active":true, - "date_joined":"2020-10-26T22:13:13.056Z", - "slack_display_name":"Qui-Gon_Jinn", - "current_lms_module":"staff", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":16, - "fields":{ - "password":"pbkdf2_sha256$216000$YkpsBjS8NCwb$FCsHB6sRkaq0dMT8fu2dw300CFwQdKJIuCJ21zLxlFE=", - "last_login":null, - "is_superuser":false, - "username":"Padme.Amidala@test.com", - "first_name":"Padme", - "last_name":"Amidala", - "email":"Padme.Amidala@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T22:16:45.860Z", - "slack_display_name":"Padme_Amidala", - "current_lms_module":"interactive_frontend_development", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":17, - "fields":{ - "password":"pbkdf2_sha256$216000$ZPzU0CSAfvXA$WTuLBfx+54/hohYzUy1HoWE7sAtBkUOM45zwJv/S9gs=", - "last_login":null, - "is_superuser":false, - "username":"Mace.Windu@test.com", - "first_name":"Mace", - "last_name":"Windu", - "email":"Mace.Windu@test.com", - "is_staff":true, - "is_active":true, - "date_joined":"2020-10-26T22:20:27.772Z", - "slack_display_name":"Mace_Windu", - "current_lms_module":"staff", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":18, - "fields":{ - "password":"pbkdf2_sha256$216000$EkH3RzLOoOM2$KAr+bqkCi8cPLPmhNnYAQV4HlfpE/2o2J0Lm5Yvw0Gc=", - "last_login":null, - "is_superuser":false, - "username":"Dooku@test.com", - "first_name":"Dooku", - "last_name":"Dooku", - "email":"Dooku@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T22:22:47.130Z", - "slack_display_name":"Dooku", - "current_lms_module":"user_centric_frontend_development", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":19, - "fields":{ - "password":"pbkdf2_sha256$216000$IaFGB8oEXeev$aJpJ4RaLttaDEnyrpY7GBRHE55ZbbN2yGFVREdH+Ioo=", - "last_login":null, - "is_superuser":false, - "username":"Jango.Fett@test.com", - "first_name":"Jango", - "last_name":"Fett", - "email":"Jango.Fett@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T22:25:11.784Z", - "slack_display_name":"Jango_Fett", - "current_lms_module":"interactive_frontend_development", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - }, - { - "model":"accounts.customuser", - "pk":20, - "fields":{ - "password":"pbkdf2_sha256$216000$8s49LY1hROQP$pMHZXrt1+FBknHA73IVN7bqyxsQcqS+tsDE4Q8Bij2s=", - "last_login":null, - "is_superuser":false, - "username":"Shmi.Skywalker@test.com", - "first_name":"Shmi", - "last_name":"Skywalker", - "email":"Shmi.Skywalker@test.com", - "is_staff":false, - "is_active":true, - "date_joined":"2020-10-26T22:28:36.422Z", - "slack_display_name":"Shmi_Skywalker", - "current_lms_module":"practical_python", - "organisation":1, - "groups":[ - - ], - "user_permissions":[ - - ] - } - } -] \ No newline at end of file diff --git a/accounts/fixtures/statuses.json b/accounts/fixtures/statuses.json new file mode 100644 index 00000000..be2c627a --- /dev/null +++ b/accounts/fixtures/statuses.json @@ -0,0 +1,145 @@ +[ + { + "model": "accounts.status", + "pk": 1, + "fields": { + "display_name": "Just started", + "level": 1, + "organisation": 1, + "admin_only": false, + "display_order": 1 + } + }, + { + "model": "accounts.status", + "pk": 2, + "fields": { + "display_name": "Studying (before Project 1)", + "level": 1, + "organisation": 1, + "admin_only": false, + "display_order": 2 + } + }, + { + "model": "accounts.status", + "pk": 3, + "fields": { + "display_name": "Studying (between Project 1 & 2)", + "level": 2, + "organisation": 1, + "admin_only": false, + "display_order": 3 + } + }, + { + "model": "accounts.status", + "pk": 4, + "fields": { + "display_name": "Studying (between Project 2 & 3)", + "level": 3, + "organisation": 1, + "admin_only": false, + "display_order": 4 + } + }, + { + "model": "accounts.status", + "pk": 5, + "fields": { + "display_name": "Studying (between Project 3 & 4)", + "level": 4, + "organisation": 1, + "admin_only": false, + "display_order": 5 + } + }, + { + "model": "accounts.status", + "pk": 6, + "fields": { + "display_name": "Studying for a (between Project 4 & 5)", + "level": 4, + "organisation": 1, + "admin_only": false, + "display_order": 6 + } + }, + { + "model": "accounts.status", + "pk": 7, + "fields": { + "display_name": "Recent Alumni", + "level": 5, + "organisation": 1, + "admin_only": false, + "display_order": 7 + } + }, + { + "model": "accounts.status", + "pk": 8, + "fields": { + "display_name": "Working as Developer 0-3 yrs", + "level": 6, + "organisation": 1, + "admin_only": false, + "display_order": 8 + } + }, + { + "model": "accounts.status", + "pk": 9, + "fields": { + "display_name": "Working as Developer 3-5 yrs", + "level": 6, + "organisation": 1, + "admin_only": false, + "display_order": 9 + } + }, + { + "model": "accounts.status", + "pk": 10, + "fields": { + "display_name": "Working as Developer 5+ yrs", + "level": 6, + "organisation": 1, + "admin_only": false, + "display_order": 10 + } + }, + { + "model": "accounts.status", + "pk": 11, + "fields": { + "display_name": "Staff (Developer)", + "level": 6, + "organisation": 1, + "admin_only": true, + "display_order": 11 + } + }, + { + "model": "accounts.status", + "pk": 12, + "fields": { + "display_name": "Staff (Non-Developer)", + "level": 1, + "organisation": 1, + "admin_only": true, + "display_order": 12 + } + }, + { + "model": "accounts.status", + "pk": 13, + "fields": { + "display_name": "Other Non-Developer", + "level": 1, + "organisation": 1, + "admin_only": false, + "display_order": 13 + } + } +] diff --git a/accounts/forms.py b/accounts/forms.py index c9bf2ba8..be9976ce 100644 --- a/accounts/forms.py +++ b/accounts/forms.py @@ -1,8 +1,8 @@ from django import forms from django.contrib.auth import get_user_model -from .lists import LMS_MODULES_CHOICES, TIMEZONE_CHOICES -from .models import CustomUser +from .lists import TIMEZONE_CHOICES +from .models import CustomUser, Status class SignupForm(forms.Form): @@ -19,9 +19,9 @@ class SignupForm(forms.Form): max_length=30, widget=forms.TextInput(attrs={'placeholder': 'Slack Display Name'}), label='') - current_lms_module = forms.CharField( - widget=forms.Select(choices=LMS_MODULES_CHOICES), - label="Where are you currently in the programme?" + status = forms.ModelChoiceField( + queryset=Status.objects.filter(admin_only=False), + label="Programming Experience" ) timezone = forms.CharField( widget=forms.Select(choices=TIMEZONE_CHOICES), @@ -31,7 +31,7 @@ class SignupForm(forms.Form): class Meta: fields = ( 'email', 'password1', 'password2', 'slack_display_name', - 'current_lms_module', 'timezone', + 'status', 'timezone', ) model = get_user_model() @@ -40,7 +40,7 @@ def signup(self, request, user): user.full_name = self.cleaned_data['full_name'] user.username = self.cleaned_data['email'] user.slack_display_name = self.cleaned_data['slack_display_name'] - user.current_lms_module = self.cleaned_data['current_lms_module'] + user.current_lms_module = self.cleaned_data['status'] user.timezone = self.cleaned_data['timezone'] user.save() @@ -58,9 +58,9 @@ class EditProfileForm(forms.ModelForm): max_length=30, widget=forms.TextInput(attrs={'placeholder': 'Slack Display Name'}), label='') - current_lms_module = forms.CharField( - widget=forms.Select(choices=LMS_MODULES_CHOICES), - label="Where are you currently in the programme?" + status = forms.ModelChoiceField( + queryset=Status.objects.filter(admin_only=False), + label="Programming Experience" ) about = forms.CharField(widget=forms.Textarea(), required=False) website_url = forms.CharField(required=False) @@ -76,9 +76,20 @@ class Meta: 'full_name', 'about', 'slack_display_name', - 'current_lms_module', + 'status', 'website_url', 'timezone', 'profile_is_public', 'email_is_public', ) + + def __init__(self, *args, **kwargs): + """ Adding extra dropdown options if user is superuser or staff """ + instance = kwargs.get('instance', None) + super(EditProfileForm, self).__init__(*args, **kwargs) + + if instance: + is_admin = instance.is_superuser or instance.is_staff + if is_admin: + self.fields['status'].queryset = Status.objects.filter( + organisation=instance.organisation) diff --git a/accounts/lists.py b/accounts/lists.py index 94d62699..d2b82e0a 100644 --- a/accounts/lists.py +++ b/accounts/lists.py @@ -12,28 +12,5 @@ ('admin', 'Admin'), ) -""" -List of CI LMS modules to be passed into dropdown of same name for each -user selection. -""" -LMS_MODULES_CHOICES = ( - ('', 'Select Learning Stage'), - ('programme_preliminaries', 'Programme Preliminaries'), - ('programming_paradigms', 'Programming Paradigms'), - ('html_essentials', 'HTML Essentials'), - ('css_essentials', 'CSS Essentials'), - ('user_centric_frontend_development', 'User Centric Frontend Development'), - ('comparative_programming_languages_essentials', - 'Comparative Programming Languages Essentials'), - ('javascript_essentials', 'Javascript Essentials'), - ('interactive_frontend_development', 'Interactive Frontend Development'), - ('python_essentials', 'Python Essentials'), - ('practical_python', 'Practical Python'), - ('data_centric_development', 'Data Centric Development'), - ('backend_development', 'Backend Development'), - ('full_stack_frameworks_with_django', 'Full Stack Frameworks with Django'), - ('alumni', 'Alumni'), - ('staff', 'Staff'), -) - TIMEZONE_CHOICES = [(tz, tz) for tz in pytz.all_timezones] + diff --git a/accounts/models.py b/accounts/models.py index 970e3f4f..29c76a01 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -5,7 +5,7 @@ from django.db import models from django.contrib.auth.models import AbstractUser -from .lists import LMS_MODULES_CHOICES, TIMEZONE_CHOICES +from .lists import TIMEZONE_CHOICES from main.models import SingletonModel from teams.lists import LMS_LEVELS @@ -39,6 +39,30 @@ def __str__(self): return self.display_name +class Status(models.Model): + """ The participant's status and experience level used for matching + students into teams """ + display_name = models.CharField(max_length=80) + level = models.IntegerField() + organisation = models.ForeignKey( + Organisation, on_delete=models.CASCADE, related_name='statuses', + default=1) + admin_only = models.BooleanField(default=False) + display_order = models.IntegerField(default=1) + + def __str__(self): + return self.display_name + + @property + def escaped_display_name(self): + return self.display_name.replace(' ', '_') + + class Meta: + ordering = ('display_order', ) + verbose_name = 'Status' + verbose_name_plural = 'Statuses' + + class CustomUser(AbstractUser): """ Custom user model extending the basic AbstractUser model """ @@ -54,11 +78,11 @@ class CustomUser(AbstractUser): default='' ) - current_lms_module = models.CharField( - max_length=50, - blank=False, - default='', - choices=LMS_MODULES_CHOICES + status = models.ForeignKey( + Status, + on_delete=models.CASCADE, + blank=True, + null=True ) organisation = models.ForeignKey( @@ -120,19 +144,16 @@ def __str__(self): """ Return Class object to string via the user email value """ return self.slack_display_name - def human_readable_current_lms_module(self): - return self.current_lms_module.replace('_', ' ') - def to_team_member(self): teams = self.participated_hackteams.filter( hackathon__status='finished') return { 'userid': self.id, 'name': self.slack_display_name or self.email, - 'level': LMS_LEVELS.get(self.current_lms_module) or 1, 'timezone': self.timezone_to_offset(), 'num_hackathons': teams.count(), 'participant_label': self.participant_label(), + 'level': self.status.level or 1 } def timezone_to_offset(self): @@ -157,6 +178,11 @@ def is_participant(self, hackathon): return self in hackathon.participants.all() + def get_level(self): + """ Get the level from the status if student has a status assigned """ + if self.status: + return self.status.level + return 1 @property def user_type(self): diff --git a/competencies/views.py b/competencies/views.py index c3bdeda8..c8024806 100644 --- a/competencies/views.py +++ b/competencies/views.py @@ -24,7 +24,7 @@ @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def list_competencies(request): competencies = Competency.objects.order_by('display_name') return render(request, 'list_competencies.html', {'competencies': competencies}) @@ -33,7 +33,7 @@ def list_competencies(request): @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def create_competency_difficulty(request): if request.method == 'POST': form = CompetencyDifficultyForm(request.POST) @@ -55,7 +55,7 @@ def create_competency_difficulty(request): @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def edit_competency_difficulty(request, competency_difficulty_id): competency_difficulty = get_object_or_404(CompetencyDifficulty, id=competency_difficulty_id) @@ -79,7 +79,7 @@ def edit_competency_difficulty(request, competency_difficulty_id): @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def create_competency(request): if request.method == 'POST': form = CompetencyForm(request.POST) @@ -100,7 +100,7 @@ def create_competency(request): @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def edit_competency(request, competency_id): competency = get_object_or_404(Competency, id=competency_id) diff --git a/hackadmin/templates/all_users.html b/hackadmin/templates/all_users.html index 86b9d628..a379d308 100644 --- a/hackadmin/templates/all_users.html +++ b/hackadmin/templates/all_users.html @@ -32,50 +32,53 @@ -
- - - - - - - - - - - - {% for user in users %} - - - - - - - - {% endfor %} -
Slack Display NameEmailCurrent LMS ModulePrivilegesActions
- {{ user.slack_display_name }} - - {{ user.email }} - - {{ user.current_lms_module }} - - {{user.user_type|readable_user_type}} - - - {% with authorised_types='SUPERUSER,STAFF,FACILITATOR_ADMIN,FACILITATOR_JUDGE,PARTNER_ADMIN,PARTNER_JUDGE' %} - {% if user.user_type|is_types:authorised_types %} - - {% endif %} - {% endwith %} -
-
+ + + + + + + + + + + + + {% for user in users %} + + + + + + + + {% endfor %} +
Slack Display NameEmailCurrent LMS ModulePrivilegesActions
+ {{ user.slack_display_name }} + + {{ user.email }} + + {% if user.status %} + {{ user.status.display_name|title }} + {% else %} + N/A + {% endif %} + + {{user.user_type|readable_user_type}} + + + {% with authorised_types='SUPERUSER,STAFF,FACILITATOR_ADMIN,FACILITATOR_JUDGE,PARTNER_ADMIN,PARTNER_JUDGE' %} + {% if user.user_type|is_types:authorised_types %} + + {% endif %} + {% endwith %} +
diff --git a/hackadmin/templates/includes/list_judges.html b/hackadmin/templates/includes/list_judges.html index 68bfead5..c9a42407 100644 --- a/hackadmin/templates/includes/list_judges.html +++ b/hackadmin/templates/includes/list_judges.html @@ -1,52 +1,49 @@ {% load hackadmin_tags %} -
- - - - - - - - - - - - {% if judges %} - {% for judge in judges %} - - - - - - - - {% endfor %} - {% else %} - - - - {% endif %} -
Slack Display NameEmailCurrent LMS ModulePrivilegesActions
- {{ judge.slack_display_name }} - - {{ judge.email }} - - {{ judge.current_lms_module }} - - {{judge.user_type|readable_user_type}} - - - {% if slack_url and not judge.is_external %} - {% split_string string=judge.username delimiter="_" index=0 as slack_username %} - - {% endif %} -
- Nobody has registered as judge for this hackathon yet. -
-
- -
- -
- + + + + + + + + + + + + {% if judges %} + {% for judge in judges %} + + + + + + + + {% endfor %} + {% else %} + + + + {% endif %} +
Slack Display NameEmailCurrent LMS ModulePrivilegesActions
+ {{ judge.slack_display_name }} + + {{ judge.email }} + + {% if judge.status %} + {{ judge.status.display_name|title }} + {% else %} + N/A + {% endif %} + + {{judge.user_type|readable_user_type}} + + + {% if slack_url and not judge.is_external %} + {% split_string string=judge.username delimiter="_" index=0 as slack_username %} + + {% endif %} +
+ Nobody has registered as judge for this hackathon yet. +
diff --git a/hackadmin/templates/includes/list_participants.html b/hackadmin/templates/includes/list_participants.html index b05a2d40..8975b081 100644 --- a/hackadmin/templates/includes/list_participants.html +++ b/hackadmin/templates/includes/list_participants.html @@ -50,6 +50,51 @@ -
- -
+ + + + + + + + + + + + {% if participants %} + {% for participant in participants %} + + + + + + + + {% endfor %} + {% else %} + + + + {% endif %} +
Slack Display NameEmailCurrent LMS ModulePrivilegesActions
+ {{ participant.slack_display_name }} + + {{ participant.email }} + + {% if participant.status %} + {{ participant.status.display_name|title }} + {% else %} + N/A + {% endif %} + + {{participant.user_type|readable_user_type}} + + + {% if slack_url and not participant.is_external %} + {% split_string string=participant.username delimiter="_" index=0 as slack_username %} + + {% endif %} + {% include 'includes/remove_participant.html' with remove_from_hackathon=True member=participant %} +
+ Nobody has registered for this hackathon yet. +
diff --git a/hackadmin/templates/list_all_users.html b/hackadmin/templates/list_all_users.html index 01625cff..9bee0b87 100644 --- a/hackadmin/templates/list_all_users.html +++ b/hackadmin/templates/list_all_users.html @@ -40,7 +40,11 @@ {{ user.email }} - {{ user.current_lms_module|readable_lms_module|title }} + {% if user.status %} + {{ user.status.display_name|title }} + {% else %} + N/A + {% endif %} {{user.user_type|readable_user_type}} diff --git a/hackadmin/templatetags/hackadmin_tags.py b/hackadmin/templatetags/hackadmin_tags.py index e383e229..4c5fc696 100644 --- a/hackadmin/templatetags/hackadmin_tags.py +++ b/hackadmin/templatetags/hackadmin_tags.py @@ -1,7 +1,5 @@ from django.template import Library -from accounts.models import UserType - register = Library() @@ -17,7 +15,7 @@ def readable_lms_module(lms_module): @register.simple_tag def split_string(**kwargs): - string=kwargs['string'] - delimiter=kwargs['delimiter'] - index=kwargs['index'] + string = kwargs['string'] + delimiter = kwargs['delimiter'] + index = kwargs['index'] return string.split(delimiter)[index] diff --git a/hackadmin/views.py b/hackadmin/views.py index 2e2ab99f..f3e0c258 100644 --- a/hackadmin/views.py +++ b/hackadmin/views.py @@ -16,7 +16,7 @@ @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def hackadmin_panel(request): """ Used for admin to view all registered users and allows to filter by individual hackathon """ @@ -32,7 +32,7 @@ def hackadmin_panel(request): @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def hackathon_participants(request, hackathon_id): """ Used for admin to view all registered users and allows to filter by individual hackathon """ @@ -64,7 +64,7 @@ def hackathon_participants(request, hackathon_id): @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def all_users(request): """ Used for admin to view all registered users and allows to filter by individual hackathon """ @@ -81,7 +81,7 @@ def all_users(request): @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def remove_participant(request, hackathon_id): if request.method == 'POST': remove_from_hackathon = (request.POST.get('remove_from_hackathon') @@ -110,7 +110,7 @@ def remove_participant(request, hackathon_id): @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def add_participant(request, hackathon_id): if request.method == 'POST': hackathon = get_object_or_404(Hackathon, id=hackathon_id) @@ -128,7 +128,7 @@ def add_participant(request, hackathon_id): @login_required @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def add_judge(request): if request.method == 'POST': hackathon = get_object_or_404(Hackathon, diff --git a/hackathon/templates/hackathon/create-event.html b/hackathon/templates/hackathon/create-event.html index f7196daf..2bcac6dc 100644 --- a/hackathon/templates/hackathon/create-event.html +++ b/hackathon/templates/hackathon/create-event.html @@ -69,7 +69,7 @@

Create Hackathon

- Cancel + Cancel
diff --git a/hackathon/tests/test_views.py b/hackathon/tests/test_views.py index 03470366..23e8a4c8 100644 --- a/hackathon/tests/test_views.py +++ b/hackathon/tests/test_views.py @@ -227,17 +227,17 @@ def test_list_partner_hackathons(self): self.client.force_login(self.user) self.assertTrue(num_hackathons <= 5) - response = self.client.get(reverse('hackathon:hackathon-list')) + response = self.client.get(reverse('hackathon:list-hackathons')) hackathons = [hackathon.id for hackathon in response.context['hackathons']] self.assertTrue(hackathon.id not in hackathons) self.client.force_login(self.staff_user) - response = self.client.get(reverse('hackathon:hackathon-list')) + response = self.client.get(reverse('hackathon:list-hackathons')) hackathons = [hackathon.id for hackathon in response.context['hackathons']] self.assertTrue(hackathon.id in hackathons) self.client.force_login(self.super_user) - response = self.client.get(reverse('hackathon:hackathon-list')) + response = self.client.get(reverse('hackathon:list-hackathons')) hackathons = [hackathon.id for hackathon in response.context['hackathons']] self.assertTrue(hackathon.id in hackathons) @@ -245,7 +245,7 @@ def test_list_partner_hackathons(self): hackathon.save() self.client.force_login(self.user) - response = self.client.get(reverse('hackathon:hackathon-list')) + response = self.client.get(reverse('hackathon:list-hackathons')) hackathons = [hackathon.id for hackathon in response.context['hackathons']] self.assertTrue(hackathon.id in hackathons) @@ -255,6 +255,6 @@ def test_list_partner_hackathons(self): self.user.save() self.client.force_login(self.user) - response = self.client.get(reverse('hackathon:hackathon-list')) + response = self.client.get(reverse('hackathon:list-hackathons')) hackathons = [hackathon.id for hackathon in response.context['hackathons']] self.assertTrue(hackathon.id in hackathons) diff --git a/hackathon/urls.py b/hackathon/urls.py index 6b411629..46210e95 100644 --- a/hackathon/urls.py +++ b/hackathon/urls.py @@ -22,7 +22,7 @@ urlpatterns = [ - path('', list_hackathons, name="hackathon-list"), + path('', list_hackathons, name="list-hackathons"), path("/team//judging/", judging, name="judging"), path("/final_score/", check_projects_scores, diff --git a/hackathon/views.py b/hackathon/views.py index fdea951d..33712650 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -88,7 +88,7 @@ def list_hackathons(request): @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.FACILITATOR_JUDGE, UserType.PARTNER_ADMIN, UserType.PARTNER_JUDGE], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def judging(request, hackathon_id, team_id): """Displays the judging page for the judge to save their scores for the selected project - determined by hackathon id and team id""" @@ -172,7 +172,7 @@ def judging(request, hackathon_id, team_id): @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, - UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') + UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def check_projects_scores(request, hackathon_id): """ When a judge submits the score, check if all projects in the Hackathon were scored by all the judges in all the categories by comparing the @@ -242,7 +242,7 @@ def check_projects_scores(request, hackathon_id): @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, - UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') + UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def create_hackathon(request): """ Allow users to create hackathon event """ if request.method == 'GET': @@ -300,12 +300,12 @@ def create_hackathon(request): logger.exception(form.errors) messages.error(request, ("An error occurred creating the event. " "Please try again.")) - return redirect("hackathon:hackathon-list") + return redirect("hackathon:list-hackathons") @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, - UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') + UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def update_hackathon(request, hackathon_id): """ Allow users to edit hackathon event """ hackathon = get_object_or_404(Hackathon, pk=hackathon_id) @@ -351,12 +351,12 @@ def update_hackathon(request, hackathon_id): else: messages.error(request, ("An error occurred updating the event. " "Please try again.")) - return redirect("hackathon:hackathon-list") + return redirect("hackathon:list-hackathons") @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, - UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') + UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def update_hackathon_status(request, hackathon_id): """ Allows users to updated the status of a hackathon """ if request.method == 'POST': @@ -369,7 +369,7 @@ def update_hackathon_status(request, hackathon_id): else: messages.error(request, ("An error occurred updating the event " "status. Please try again.")) - return redirect("hackathon:hackathon-list") + return redirect("hackathon:list-hackathons") @login_required @@ -424,7 +424,7 @@ def view_hackathon_public(request, hackathon_id): @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, - UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') + UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def delete_hackathon(request, hackathon_id): """ Allow users to 'soft delete' hackathon event - set status to 'deleted' to remove from frontend list """ @@ -437,7 +437,7 @@ def delete_hackathon(request, hackathon_id): messages.success( request, f'{hackathon.display_name} has been successfully deleted!') - return redirect("hackathon:hackathon-list") + return redirect("hackathon:list-hackathons") @login_required @@ -484,7 +484,7 @@ def enroll_toggle(request): @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, - UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') + UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def change_awards(request, hackathon_id): hackathon = get_object_or_404(Hackathon, pk=hackathon_id) awards = hackathon.awards.all() @@ -536,7 +536,7 @@ def change_awards(request, hackathon_id): @can_access([UserType.SUPERUSER, UserType.STAFF, UserType.FACILITATOR_ADMIN, UserType.FACILITATOR_JUDGE, UserType.PARTNER_ADMIN, UserType.PARTNER_JUDGE], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def judge_teams(request, hackathon_id): """ Shows the list of teams and allows a judge to go to the scoring page """ @@ -554,7 +554,7 @@ def judge_teams(request, hackathon_id): @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, - UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') + UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def assign_mentors(request, hackathon_id): """ View used to assign a mentor to each team """ hackathon = get_object_or_404(Hackathon, id=hackathon_id) @@ -589,7 +589,7 @@ def assign_mentors(request, hackathon_id): @login_required -@can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') +@can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def hackathon_events(request, hackathon_id): hackathon = get_object_or_404(Hackathon, pk=hackathon_id) events = Event.objects.filter(hackathon=hackathon) @@ -604,7 +604,7 @@ def hackathon_events(request, hackathon_id): @login_required -@can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') +@can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def hackathon_events_endpoint(request, hackathon_id): hackathon = get_object_or_404(Hackathon, pk=hackathon_id) events = Event.objects.filter(hackathon=hackathon) @@ -621,7 +621,7 @@ def hackathon_events_endpoint(request, hackathon_id): @login_required -@can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') +@can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def change_event(request, hackathon_id, event_id=None): hackathon = get_object_or_404(Hackathon, pk=hackathon_id) event = get_object_or_404(Event, pk=event_id) if event_id else None @@ -646,7 +646,7 @@ def change_event(request, hackathon_id, event_id=None): }) @login_required -@can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], redirect_url='hackathon:hackathon-list') +@can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], redirect_url='hackathon:list-hackathons') def delete_event(request, hackathon_id, event_id): event = get_object_or_404(Event, pk=event_id) event.delete() diff --git a/home/templates/home/index.html b/home/templates/home/index.html index 587178c0..295b246a 100644 --- a/home/templates/home/index.html +++ b/home/templates/home/index.html @@ -6,7 +6,7 @@ {% block content %} -
+
@@ -25,7 +25,7 @@ {% for hackathon in recent_hackathons %} {% include 'includes/hackathon_square.html' %} {% endfor %} - {% include 'includes/link_square.html' with label="See All Hackathons" redirect_url="hackathon:hackathon-list" %} + {% include 'includes/link_square.html' with label="See All Hackathons" redirect_url="hackathon:list-hackathons" %}
{% endif %} diff --git a/home/views.py b/home/views.py index 1d74091d..733b8fdc 100644 --- a/home/views.py +++ b/home/views.py @@ -22,7 +22,7 @@ def index(request): user's full name is present, if it is not redirect to edit profile, otherwise redirect to home """ - if not request.user.current_lms_module: + if not request.user.status: messages.warning(request, 'Please fill in your profile.') return redirect(reverse('edit_profile')) diff --git a/profiles/templates/profiles/profile.html b/profiles/templates/profiles/profile.html index eb0e6a63..d4194223 100644 --- a/profiles/templates/profiles/profile.html +++ b/profiles/templates/profiles/profile.html @@ -71,9 +71,13 @@

{% if user.about %}{{ user.about }}{% else %}N/A{% endif %}

- +

- {{ user.human_readable_current_lms_module|title }} + {% if user.status %} + {{ user.status.display_name|title }} + {% else %} + N/A + {% endif %}

diff --git a/scripts/docker_seed.sh b/scripts/docker_seed.sh index 0eff5ea1..f2195afa 100755 --- a/scripts/docker_seed.sh +++ b/scripts/docker_seed.sh @@ -1,7 +1,9 @@ echo "============================" echo "Seeding fixtures" echo "============================" +docker-compose exec hackathon-app python3 manage.py loaddata groups docker compose exec hackathon-app python3 manage.py loaddata organisation +docker-compose exec hackathon-app python3 manage.py loaddata statuses docker compose exec hackathon-app python3 manage.py loaddata accounts docker compose exec hackathon-app python3 manage.py loaddata resources docker compose exec hackathon-app python3 manage.py loaddata profiles @@ -10,3 +12,4 @@ docker compose exec hackathon-app python3 manage.py loaddata hackathons docker compose exec hackathon-app python3 manage.py loaddata showcase docker compose exec hackathon-app python3 manage.py loaddata showcase_site_settings docker compose exec hackathon-app python3 manage.py loaddata reviews + diff --git a/scripts/seed.bat b/scripts/seed.bat index a0cbcb78..1136e072 100644 --- a/scripts/seed.bat +++ b/scripts/seed.bat @@ -1,5 +1,7 @@ ECHO Seeding fixtures +python manage.py loaddata groups python manage.py loaddata organisation +python manage.py loaddata statuses python manage.py loaddata accounts python manage.py loaddata resources python manage.py loaddata profiles diff --git a/scripts/seed.sh b/scripts/seed.sh index 54f546d6..a7f31c97 100755 --- a/scripts/seed.sh +++ b/scripts/seed.sh @@ -1,7 +1,9 @@ echo "============================" echo "Seeding fixtures" echo "============================" +python3 manage.py loaddata groups python3 manage.py loaddata organisation +python3 manage.py loaddata statuses python3 manage.py loaddata accounts python3 manage.py loaddata resources python3 manage.py loaddata profiles diff --git a/static/css/home.css b/static/css/home.css index 446ab8db..670895f8 100644 --- a/static/css/home.css +++ b/static/css/home.css @@ -1,10 +1,16 @@ .container.main-content-shadow { - margin-bottom: 0; margin: 0; + margin-top: 32px; width: 100%; max-width: none; } +.alert { + margin: 0 auto; + margin-bottom: 10px; + max-width: 1140px +} + .hack-card { margin-bottom: 1rem; } diff --git a/teams/helpers.py b/teams/helpers.py index b7109acc..978cd327 100644 --- a/teams/helpers.py +++ b/teams/helpers.py @@ -5,7 +5,6 @@ import pytz -from .lists import LMS_LEVELS from accounts.models import CustomUser from hackathon.models import Hackathon, HackTeam @@ -73,8 +72,7 @@ def group_participants(participants, num_teams): participant_groups = {} hackathon_level = 0 for participant in participants: - participant_level = (LMS_LEVELS.get(participant.current_lms_module) - or 1) + participant_level = participant.get_level() hackathon_level += participant_level participant_groups.setdefault(participant_level, []) participant_groups[participant_level].append( @@ -116,8 +114,9 @@ def find_all_combinations(participants, team_sizes): Returns a list of tuples representing all the possible combinations """ num_teams = len(team_sizes) - participant_levels = [LMS_LEVELS.get(participant.current_lms_module) or 1 - for participant in participants] + participant_levels = [ + (participant.status.level or 1) if participant.status else 1 + for participant in participants] hackathon_level = sum(participant_levels) team_level = math.floor(hackathon_level / num_teams) missing = hackathon_level - (num_teams * team_level) diff --git a/teams/tests.py b/teams/tests.py index 49ef1649..9ce714fa 100644 --- a/teams/tests.py +++ b/teams/tests.py @@ -17,9 +17,9 @@ class TeamsHelpersTestCase(TestCase): def setUp(self): call_command('loaddata', 'organisation', verbosity=0) + call_command('loaddata', 'statuses', verbosity=0) call_command('loaddata', 'accounts', verbosity=0) call_command('loaddata', 'resources', verbosity=0) - call_command('loaddata', 'profiles', verbosity=0) call_command('loaddata', 'emailaddresses', verbosity=0) call_command('loaddata', 'hackathons', verbosity=0) @@ -136,9 +136,9 @@ def test_create_teams_in_view(self): class TeamsViewsTestCase(TestCase): def setUp(self): call_command('loaddata', 'organisation', verbosity=0) + call_command('loaddata', 'statuses', verbosity=0) call_command('loaddata', 'accounts', verbosity=0) call_command('loaddata', 'resources', verbosity=0) - call_command('loaddata', 'profiles', verbosity=0) call_command('loaddata', 'emailaddresses', verbosity=0) call_command('loaddata', 'hackathons', verbosity=0) diff --git a/teams/views.py b/teams/views.py index 10d2c5de..2b3284dc 100644 --- a/teams/views.py +++ b/teams/views.py @@ -30,7 +30,7 @@ @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def change_teams(request, hackathon_id): """ Page that handles the logic of automatically distributing the teams for a hackathon and allows for the admin to re-arrange the team members """ @@ -83,7 +83,7 @@ def change_teams(request, hackathon_id): @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def create_teams(request): """ View used to save the hackathon teams created by an admin """ if request.method == 'POST': @@ -104,13 +104,13 @@ def create_teams(request): return redirect(reverse('hackathon:change_teams', kwargs={'hackathon_id': hackathon_id})) else: - return redirect(reverse('hackathon:hackathon-list')) + return redirect(reverse('hackathon:list-hackathons')) @login_required @can_access([UserType.SUPERUSER, UserType.FACILITATOR_ADMIN, UserType.PARTNER_ADMIN], - redirect_url='hackathon:hackathon-list') + redirect_url='hackathon:list-hackathons') def clear_teams(request): """ Reset all teams for a specific hackathon """ if request.method == 'POST': @@ -122,7 +122,7 @@ def clear_teams(request): return redirect(reverse('hackathon:change_teams', kwargs={'hackathon_id': hackathon_id})) else: - return redirect(reverse('hackathon:hackathon-list')) + return redirect(reverse('hackathon:list-hackathons')) @login_required diff --git a/templates/base.html b/templates/base.html index 1fd72675..537752b5 100644 --- a/templates/base.html +++ b/templates/base.html @@ -30,7 +30,7 @@
- {% if request.user.is_authenticated and not request.user.current_lms_module %} + {% if request.user.is_authenticated and not request.user.status %}