Skip to content

Commit 414d4c4

Browse files
authored
Merge pull request #2 from tamarinvs19/interface
First version
2 parents 90d3a1e + ae5e99e commit 414d4c4

File tree

142 files changed

+4106
-345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+4106
-345
lines changed

.github/workflows/django.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
max-parallel: 4
1515
matrix:
16-
python-version: [3.9]
16+
python-version: ["3.10"]
1717

1818
steps:
1919
- uses: actions/checkout@v2
@@ -28,6 +28,8 @@ jobs:
2828
- name: Run Tests
2929
shell: bash
3030
env:
31-
SECRET_KEY: ${{ secrets.SECRET_KEY }}
31+
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
32+
SLACK_SECRET: ${{ secrets.SLACK_SECRET }}
33+
SLACK_CLIENT_ID: ${{ secrets.SLACK_CLIENT_ID }}
3234
run: |
3335
python manage.py test

.gitignore

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# DB
22
*.sqlite3
33

4+
# Django
45
staticfiles
5-
*.log
6-
.cache_ggshield
6+
*compressed_static/
77

8+
# Python
89
__pycache__/
9-
*compressed_static/
1010

1111
# Environments
1212
.env
@@ -15,5 +15,12 @@ env/
1515
venv/
1616

1717
# config
18-
.env_variables
1918
choosing_electives.ini
19+
20+
# Dependencies
21+
/node_modules/
22+
package-lock.json
23+
24+
*.log
25+
.cache_ggshield
26+

choosing_electives/settings.py

+32-2
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@
1111
env = Env(
1212
DEBUG=(True, bool),
1313
)
14-
env.read_env()
14+
env.read_env(file_name='.env')
1515

16-
SECRET_KEY = os.environ.get('SECRET_KEY') or env['SECRET_KEY']
16+
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY') or env['DJANGO_SECRET_KEY']
1717

1818
DEBUG = env['DEBUG']
1919

2020
ALLOWED_HOSTS = [
2121
'localhost',
2222
'127.0.0.1',
23+
'ec27-45-93-133-191.ngrok.io',
2324
]
2425

26+
AUTHENTICATION_BACKENDS = [
27+
'django.contrib.auth.backends.ModelBackend',
28+
'allauth.account.auth_backends.AuthenticationBackend',
29+
]
2530

2631
# Application definition
2732

@@ -35,8 +40,33 @@
3540
'django.contrib.sessions',
3641
'django.contrib.messages',
3742
'django.contrib.staticfiles',
43+
'django.contrib.sites',
44+
45+
'allauth',
46+
'allauth.account',
47+
'allauth.socialaccount',
48+
'allauth.socialaccount.providers.slack',
3849
]
3950

51+
SITE_ID = 1
52+
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
53+
54+
# Provider specific settings
55+
SOCIALACCOUNT_PROVIDERS = {
56+
'slack': {
57+
'APP': {
58+
'client_id': os.environ.get('SLACK_CLIENT_ID') or env['SLACK_CLIENT_ID'],
59+
'secret': os.environ.get('SLACK_SECRET') or env['SLACK_SECRET'],
60+
},
61+
'SCOPE': ['identity.basic', 'identity.email', 'openid'],
62+
}
63+
}
64+
LOGIN_URL = '/electives/accounts/login/'
65+
LOGIN_REDIRECT_URL = '/electives/'
66+
ACCOUNT_LOGOUT_REDIRECT_URL = '/electives/accounts/login/'
67+
ACCOUNT_SIGNUP_REDIRECT_URL = "/electives/account/post_registration/"
68+
69+
4070
MIDDLEWARE = [
4171
'django.middleware.security.SecurityMiddleware',
4272
'django.contrib.sessions.middleware.SessionMiddleware',

choosing_electives/urls.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from django.urls import path, include
1818

1919
urlpatterns = [
20-
path('admin/', admin.site.urls),
20+
path('electives/admin/', admin.site.urls),
2121
path('electives/', include('electives.urls')),
22-
path('users/', include('users.urls')),
22+
path('electives/users/', include('users.urls')),
23+
path('electives/accounts/', include('allauth.urls')),
2324
]

electives/admin.py

+23-15
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
from django.contrib import admin
2-
from .models import Elective, StudentOnElective, TeacherOnElective, KindOfElective, ElectiveKind, ElectiveThematic, \
3-
MandatoryElectiveInStudentGroup
2+
from .models import Elective, StudentOnElective, KindOfElective, ElectiveKind, ElectiveThematic, \
3+
MandatoryThematicInStudentGroup
44

55

66
class StudentOnElectiveInline(admin.TabularInline):
77
model = StudentOnElective
88
extra = 2
99

1010

11-
class TeacherOnElectiveInline(admin.TabularInline):
12-
model = TeacherOnElective
13-
extra = 1
14-
15-
1611
class KindOfElectiveInline(admin.TabularInline):
1712
model = KindOfElective
1813
extra = 1
1914

2015

21-
class MandatoryElectiveForStudentGroupInline(admin.TabularInline):
22-
model = MandatoryElectiveInStudentGroup
16+
class MandatoryThematicInline(admin.TabularInline):
17+
model = MandatoryThematicInStudentGroup
2318
extra = 1
2419

2520

2621
class ElectiveAdmin(admin.ModelAdmin):
2722
fieldsets = [
28-
(None, {'fields': ['name', 'codename', 'description', 'thematic', 'text_teachers']}),
23+
(None, {'fields': ['name', 'english_name', 'codename', 'description',
24+
'english_description', 'thematic', 'text_teachers']}),
2925
('Number of students', {'fields': ['min_number_students', 'max_number_students']}),
3026
]
31-
inlines = [KindOfElectiveInline, TeacherOnElectiveInline,
32-
StudentOnElectiveInline, MandatoryElectiveForStudentGroupInline]
27+
inlines = [
28+
KindOfElectiveInline,
29+
StudentOnElectiveInline,
30+
]
3331
list_display = ('name',)
3432
search_fields = ['name']
3533

@@ -43,12 +41,22 @@ class ElectiveKindAdmin(admin.ModelAdmin):
4341

4442
class ElectiveThematicAdmin(admin.ModelAdmin):
4543
fieldsets = [
46-
(None, {'fields': ['name']}),
44+
(None, {'fields': ['name', 'english_name']}),
4745
]
48-
list_display = ('name',)
46+
inlines = [
47+
MandatoryThematicInline,
48+
]
49+
list_display = ('name', 'english_name')
50+
51+
52+
class ApplicationAdmin(admin.ModelAdmin):
53+
fieldsets = [
54+
(None, {'fields': ['student', 'elective', 'kind', 'with_examination', 'attached', 'priority']}),
55+
]
56+
list_display = ('student', 'elective', 'kind', 'attached', 'priority')
4957

5058

5159
admin.site.register(Elective, ElectiveAdmin)
5260
admin.site.register(ElectiveKind, ElectiveKindAdmin)
5361
admin.site.register(ElectiveThematic, ElectiveThematicAdmin)
54-
62+
admin.site.register(StudentOnElective, ApplicationAdmin)

0 commit comments

Comments
 (0)