Skip to content

Commit

Permalink
Merge pull request #2 from tamarinvs19/interface
Browse files Browse the repository at this point in the history
First version
  • Loading branch information
tamarinvs19 authored Dec 22, 2021
2 parents 90d3a1e + ae5e99e commit 414d4c4
Show file tree
Hide file tree
Showing 142 changed files with 4,106 additions and 345 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.9]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
Expand All @@ -28,6 +28,8 @@ jobs:
- name: Run Tests
shell: bash
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
SLACK_SECRET: ${{ secrets.SLACK_SECRET }}
SLACK_CLIENT_ID: ${{ secrets.SLACK_CLIENT_ID }}
run: |
python manage.py test
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# DB
*.sqlite3

# Django
staticfiles
*.log
.cache_ggshield
*compressed_static/

# Python
__pycache__/
*compressed_static/

# Environments
.env
Expand All @@ -15,5 +15,12 @@ env/
venv/

# config
.env_variables
choosing_electives.ini

# Dependencies
/node_modules/
package-lock.json

*.log
.cache_ggshield

34 changes: 32 additions & 2 deletions choosing_electives/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
env = Env(
DEBUG=(True, bool),
)
env.read_env()
env.read_env(file_name='.env')

SECRET_KEY = os.environ.get('SECRET_KEY') or env['SECRET_KEY']
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY') or env['DJANGO_SECRET_KEY']

DEBUG = env['DEBUG']

ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
'ec27-45-93-133-191.ngrok.io',
]

AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
]

# Application definition

Expand All @@ -35,8 +40,33 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',

'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.slack',
]

SITE_ID = 1
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'

# Provider specific settings
SOCIALACCOUNT_PROVIDERS = {
'slack': {
'APP': {
'client_id': os.environ.get('SLACK_CLIENT_ID') or env['SLACK_CLIENT_ID'],
'secret': os.environ.get('SLACK_SECRET') or env['SLACK_SECRET'],
},
'SCOPE': ['identity.basic', 'identity.email', 'openid'],
}
}
LOGIN_URL = '/electives/accounts/login/'
LOGIN_REDIRECT_URL = '/electives/'
ACCOUNT_LOGOUT_REDIRECT_URL = '/electives/accounts/login/'
ACCOUNT_SIGNUP_REDIRECT_URL = "/electives/account/post_registration/"


MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
Expand Down
5 changes: 3 additions & 2 deletions choosing_electives/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('electives/admin/', admin.site.urls),
path('electives/', include('electives.urls')),
path('users/', include('users.urls')),
path('electives/users/', include('users.urls')),
path('electives/accounts/', include('allauth.urls')),
]
38 changes: 23 additions & 15 deletions electives/admin.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
from django.contrib import admin
from .models import Elective, StudentOnElective, TeacherOnElective, KindOfElective, ElectiveKind, ElectiveThematic, \
MandatoryElectiveInStudentGroup
from .models import Elective, StudentOnElective, KindOfElective, ElectiveKind, ElectiveThematic, \
MandatoryThematicInStudentGroup


class StudentOnElectiveInline(admin.TabularInline):
model = StudentOnElective
extra = 2


class TeacherOnElectiveInline(admin.TabularInline):
model = TeacherOnElective
extra = 1


class KindOfElectiveInline(admin.TabularInline):
model = KindOfElective
extra = 1


class MandatoryElectiveForStudentGroupInline(admin.TabularInline):
model = MandatoryElectiveInStudentGroup
class MandatoryThematicInline(admin.TabularInline):
model = MandatoryThematicInStudentGroup
extra = 1


class ElectiveAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['name', 'codename', 'description', 'thematic', 'text_teachers']}),
(None, {'fields': ['name', 'english_name', 'codename', 'description',
'english_description', 'thematic', 'text_teachers']}),
('Number of students', {'fields': ['min_number_students', 'max_number_students']}),
]
inlines = [KindOfElectiveInline, TeacherOnElectiveInline,
StudentOnElectiveInline, MandatoryElectiveForStudentGroupInline]
inlines = [
KindOfElectiveInline,
StudentOnElectiveInline,
]
list_display = ('name',)
search_fields = ['name']

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

class ElectiveThematicAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['name']}),
(None, {'fields': ['name', 'english_name']}),
]
list_display = ('name',)
inlines = [
MandatoryThematicInline,
]
list_display = ('name', 'english_name')


class ApplicationAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['student', 'elective', 'kind', 'with_examination', 'attached', 'priority']}),
]
list_display = ('student', 'elective', 'kind', 'attached', 'priority')


admin.site.register(Elective, ElectiveAdmin)
admin.site.register(ElectiveKind, ElectiveKindAdmin)
admin.site.register(ElectiveThematic, ElectiveThematicAdmin)

admin.site.register(StudentOnElective, ApplicationAdmin)
Loading

0 comments on commit 414d4c4

Please sign in to comment.