Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#M27. Add "Status" model to replace "Last LMS module" field with a Foreignkey. #236

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
8 changes: 5 additions & 3 deletions accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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',
Expand All @@ -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')
Expand All @@ -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)

6 changes: 3 additions & 3 deletions accounts/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
Loading