-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
370 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django.shortcuts import redirect | ||
from django.conf import settings | ||
|
||
|
||
class LoginRequiredMiddleware: | ||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
self.login_url = settings.LOGIN_URL | ||
self.open_urls = [self.login_url] + \ | ||
getattr(settings, 'OPEN_URLS', []) | ||
|
||
def __call__(self, request): | ||
if not request.user.is_authenticated \ | ||
and not request.path_info in self.open_urls: | ||
return redirect(self.login_url+'?next='+request.path) | ||
|
||
return self.get_response(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from crispy_forms.helper import FormHelper | ||
from crispy_forms.layout import Submit | ||
from django.forms import ModelForm | ||
|
||
from programdom.models import Module | ||
|
||
|
||
class ModuleForm(ModelForm): | ||
def __init__(self, *args, **kwargs): | ||
super(ModuleForm, self).__init__(*args, **kwargs) | ||
self.helper = FormHelper(self) | ||
self.helper.add_input(Submit('submit', 'Submit', css_class='btn-primary')) | ||
|
||
class Meta: | ||
model = Module | ||
fields = ['name', 'code'] | ||
|
||
|
||
class ModuleUsersForm(ModelForm): | ||
def __init__(self, *args, **kwargs): | ||
super(ModuleUsersForm, self).__init__(*args, **kwargs) | ||
self.helper = FormHelper(self) | ||
self.helper.add_input(Submit('submit', 'Submit', css_class='btn-primary')) | ||
|
||
class Meta: | ||
model = Module | ||
fields = ['users', ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from django.urls import path | ||
|
||
from programdom.modules.views import MyModulesView, ModuleDetailView | ||
from programdom.modules.views import MyModulesView, ModuleDetailView, ModuleCreateView, ModuleEditUsersView | ||
|
||
urlpatterns = [ | ||
path("", MyModulesView.as_view(), name="module_list"), | ||
path("<code>/", ModuleDetailView.as_view(), name="module_detail") | ||
path("new/", ModuleCreateView.as_view(), name="module_new"), | ||
path("<code>/", ModuleDetailView.as_view(), name="module_detail"), | ||
path("<code>/users/update", ModuleEditUsersView.as_view(), name="module_users_update"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.