Skip to content

Commit

Permalink
Make invitation editable on creation of student profile (#910)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmi4er4 authored Nov 11, 2024
1 parent d5920bb commit a136528
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 104 deletions.
2 changes: 1 addition & 1 deletion apps/admission/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-10 12:50+0000\n"
"POT-Creation-Date: 2024-11-11 10:13+0000\n"
"PO-Revision-Date: 2024-07-23 17:04+0000\n"
"Last-Translator: Дмитрий Чернушевич <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion apps/htmlpages/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: django\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-10 12:50+0000\n"
"POT-Creation-Date: 2024-11-11 10:13+0000\n"
"PO-Revision-Date: 2015-03-18 08:34+0000\n"
"Last-Translator: Jannis Leidel <[email protected]>\n"
"Language-Team: Russian (http://www.transifex.com/projects/p/django/language/"
Expand Down
1 change: 1 addition & 0 deletions apps/learning/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ class CourseInlineAdmin(admin.TabularInline):


class InvitationAdmin(BaseModelAdmin):
search_fields = ['name']
list_display = ('name', 'get_branches', 'semester', 'get_link')
list_select_related = ['semester']
list_prefetch_related = ['branches']
Expand Down
2 changes: 1 addition & 1 deletion apps/projects/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-10 12:50+0000\n"
"POT-Creation-Date: 2024-11-11 10:13+0000\n"
"PO-Revision-Date: 2022-02-21 15:24+0000\n"
"Last-Translator: Сергей Жеревчук <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion apps/surveys/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-10 12:50+0000\n"
"POT-Creation-Date: 2024-11-11 10:13+0000\n"
"PO-Revision-Date: 2019-10-31 16:30+0000\n"
"Last-Translator: b' <[email protected]>'\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
7 changes: 6 additions & 1 deletion apps/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class Meta:
def clean(self):
cleaned_data = super().clean()
profile_type = cleaned_data.get('type')
invitation = cleaned_data.get('invitation')
user = cleaned_data.get('user')
branch = cleaned_data.get('branch')
year_of_admission = cleaned_data.get('year_of_admission')
Expand All @@ -209,6 +210,9 @@ def clean(self):
msg = _('Regular student profile already exists for this '
'admission campaign year.')
self.add_error('year_of_admission', ValidationError(msg))
if profile_type == StudentTypes.INVITED and invitation is None:
msg = _('Student profile with type INVITED must have invitation')
self.add_error('invitation', ValidationError(msg))


class StudentProfileAdmin(BaseModelAdmin):
Expand All @@ -218,6 +222,7 @@ class StudentProfileAdmin(BaseModelAdmin):
list_filter = ('type', 'site', 'branch', 'status',)
raw_id_fields = ('user', 'comment_last_author')
search_fields = ['user__last_name']
raw_id_fields = ['invitation']
inlines = [StudentStatusLogAdminInline, StudentAcademicDisciplineLogAdminInline]
formfield_overrides = {
models.ManyToManyField: {
Expand All @@ -230,7 +235,7 @@ def get_readonly_fields(self, request, obj=None):
# TODO: add user change url
return ['type', 'site', 'year_of_admission', 'birth_date',
'comment_changed_at', 'comment_last_author', 'invitation']
return ['birth_date', 'invitation']
return ['birth_date']

def get_fieldsets(self, request, obj=None):
fieldsets = [
Expand Down
1 change: 0 additions & 1 deletion apps/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@ class StudentProfile(TimeStampedModel):
invitation = models.ForeignKey(
"learning.Invitation",
verbose_name=_("Invitation"),
editable=False,
blank=True, null=True,
related_name="student_profiles",
on_delete=models.SET_NULL)
Expand Down
2 changes: 1 addition & 1 deletion compscicenter_ru/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-10 12:50+0000\n"
"POT-Creation-Date: 2024-11-11 10:13+0000\n"
"PO-Revision-Date: 2020-02-03 16:52+0000\n"
"Last-Translator: b' <[email protected]>'\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion compsciclub_ru/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-10 12:50+0000\n"
"POT-Creation-Date: 2024-11-11 10:13+0000\n"
"PO-Revision-Date: 2020-09-09 04:43+0000\n"
"Last-Translator: b' <[email protected]>'\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
Loading

0 comments on commit a136528

Please sign in to comment.