Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=mysecretpassword

# Salesforce
SALESFORCE_KEY=
SALESFORCE_SECRET=
SALESFORCE_USER=
SALESFORCE_PASSWORD=
SALESFORCE_HOST=https://test.salesforce.com

# Email
[email protected]
[email protected]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ docker-compose run --rm app python manage.py migrate
```console
docker kill $(docker ps -q); docker-compose rm -f; docker volume rm $(docker volume ls -qf dangling=true);
```

n
- Rebuild docker containers after major changes:

```console
Expand Down
60 changes: 30 additions & 30 deletions coderdojochi/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,30 @@ class MentorAdmin(ImportExportMixin, ImportExportActionModelAdmin):
"last_name",
"user_link",
"mentor_count_link",
"created_at",
"updated_at",
# "created_at",
# "updated_at",
"is_active",
"is_public",
"background_check",
"avatar_approved",
# "avatar_approved",
]

list_filter = [
"is_active",
"is_public",
"background_check",
"avatar_approved",
# "avatar_approved",
]

list_select_related = [
"user",
]

ordering = [
"-created_at",
# "-created_at",
]

date_hierarchy = "created_at"
# date_hierarchy = "created_at"

search_fields = [
"user__first_name",
Expand All @@ -151,7 +151,7 @@ class MentorAdmin(ImportExportMixin, ImportExportActionModelAdmin):
]

filter_horizontal = [
"race_ethnicity",
# "race_ethnicity",
]

def view_on_site(self, obj):
Expand Down Expand Up @@ -253,12 +253,12 @@ class GuardianAdmin(ImportExportMixin, ImportExportActionModelAdmin):
"last_name",
"student_count_link",
"user_link",
"created_at",
"updated_at",
# "created_at",
# "updated_at",
]

list_filter = [
"zip",
# "zip",
]

list_select_related = [
Expand All @@ -282,10 +282,10 @@ class GuardianAdmin(ImportExportMixin, ImportExportActionModelAdmin):
]

filter_horizontal = [
"race_ethnicity",
# "race_ethnicity",
]

date_hierarchy = "created_at"
# date_hierarchy = "created_at"

view_on_site = False

Expand Down Expand Up @@ -410,7 +410,7 @@ class StudentAdmin(ImportExportMixin, ImportExportActionModelAdmin):
]

filter_horizontal = [
"race_ethnicity",
# "race_ethnicity",
]

ordering = [
Expand All @@ -428,7 +428,7 @@ class StudentAdmin(ImportExportMixin, ImportExportActionModelAdmin):
"guardian",
]

date_hierarchy = "created_at"
# date_hierarchy = "created_at"

view_on_site = False

Expand Down Expand Up @@ -499,17 +499,17 @@ class CourseAdmin(ImportExportMixin, ImportExportActionModelAdmin):

ordering = [
"code",
"created_at",
# "created_at",
]

search_fields = [
"title",
"description",
]

prepopulated_fields = {
"slug": ("title",),
}
# prepopulated_fields = {
# "slug": ("title",),
# }

view_on_site = False

Expand Down Expand Up @@ -551,7 +551,7 @@ class SessionAdmin(ImportExportMixin, ImportExportActionModelAdmin):
filter_horizontal = [
# "waitlist_mentors",
# "waitlist_students",
"assistant",
# "assistant",
]

# autocomplete_fields = [
Expand Down Expand Up @@ -687,7 +687,7 @@ class OrderAdmin(ImportExportMixin, ImportExportActionModelAdmin):
"get_student_age",
"get_guardian_link",
"get_session_link",
"_created_at",
# "_created_at",
"is_checked_in",
"is_active",
]
Expand All @@ -710,16 +710,16 @@ class OrderAdmin(ImportExportMixin, ImportExportActionModelAdmin):
]

ordering = [
"created_at",
# "created_at",
]

autocomplete_fields = [
"guardian",
# "guardian",
"session",
"student",
]

date_hierarchy = "created_at"
# date_hierarchy = "created_at"

view_on_site = False

Expand Down Expand Up @@ -755,10 +755,10 @@ def get_session_link(self, obj):

get_session_link.short_description = "Session"

def _created_at(self, obj):
return obj.created_at.strftime("%m/%d/%y %H:%M")
# def _created_at(self, obj):
# return obj.created_at.strftime("%m/%d/%y %H:%M")

_created_at.short_description = "Created At"
# _created_at.short_description = "Created At"


def mentor_check_in(modeladmin, request, queryset):
Expand Down Expand Up @@ -787,8 +787,8 @@ class MentorOrderAdmin(ImportExportMixin, ImportExportActionModelAdmin):
"is_active",
"week_reminder_sent",
"day_reminder_sent",
"created_at",
"updated_at",
# "created_at",
# "updated_at",
]

list_display_links = [
Expand All @@ -807,7 +807,7 @@ class MentorOrderAdmin(ImportExportMixin, ImportExportActionModelAdmin):
]

ordering = [
"created_at",
# "created_at",
]

search_fields = [
Expand All @@ -829,7 +829,7 @@ class MentorOrderAdmin(ImportExportMixin, ImportExportActionModelAdmin):
mentor_check_out,
]

date_hierarchy = "created_at"
# date_hierarchy = "created_at"
view_on_site = False


Expand Down
55 changes: 28 additions & 27 deletions coderdojochi/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,42 +126,43 @@ class MentorForm(CDCModelForm):

class Meta:
model = Mentor
fields = ("bio", "avatar", "gender", "race_ethnicity", "birthday", "phone", "home_address", "work_place")
#"avatar",
fields = ("bio", "gender", "race_ethnicity", "birthday", "phone", "home_address", "work_place")

def clean_avatar(self):
avatar = self.cleaned_data["avatar"]
# def clean_avatar(self):
# avatar = self.cleaned_data["avatar"]

if avatar is None:
return avatar
# if avatar is None:
# return avatar

try:
w, h = get_image_dimensions(avatar)
# try:
# w, h = get_image_dimensions(avatar)

# validate dimensions
max_width = max_height = 1000
if w > max_width or h > max_height:
raise forms.ValidationError(f"Please use an image that is {max_width} x {max_height}px or smaller.")
# # validate dimensions
# max_width = max_height = 1000
# if w > max_width or h > max_height:
# raise forms.ValidationError(f"Please use an image that is {max_width} x {max_height}px or smaller.")

min_width = min_height = 500
if w < min_width or h < min_height:
raise forms.ValidationError(f"Please use an image that is {min_width} x {min_height}px or larger.")
# min_width = min_height = 500
# if w < min_width or h < min_height:
# raise forms.ValidationError(f"Please use an image that is {min_width} x {min_height}px or larger.")

# validate content type
main, sub = avatar.content_type.split("/")
if not (main == "image" and sub in ["jpeg", "pjpeg", "gif", "png"]):
raise forms.ValidationError("Please use a JPEG, GIF or PNG image.")
# # validate content type
# main, sub = avatar.content_type.split("/")
# if not (main == "image" and sub in ["jpeg", "pjpeg", "gif", "png"]):
# raise forms.ValidationError("Please use a JPEG, GIF or PNG image.")

# validate file size
if len(avatar) > (2000 * 1024):
raise forms.ValidationError("Avatar file size may not exceed 2MB.")
# # validate file size
# if len(avatar) > (2000 * 1024):
# raise forms.ValidationError("Avatar file size may not exceed 2MB.")

except AttributeError:
"""
Handles case when we are updating the user profile
and do not supply a new avatar
"""
# except AttributeError:
# """
# Handles case when we are updating the user profile
# and do not supply a new avatar
# """

return avatar
# return avatar


class GuardianForm(CDCModelForm):
Expand Down
Loading