diff --git a/chat_box/migrations/0016_alter_room_unique_together.py b/chat_box/migrations/0016_alter_room_unique_together.py new file mode 100644 index 0000000..14b784a --- /dev/null +++ b/chat_box/migrations/0016_alter_room_unique_together.py @@ -0,0 +1,32 @@ +# Generated by Django 3.2.18 on 2024-08-22 03:12 + +from django.db import migrations, models + + +def remove_duplicates(apps, schema_editor): + Room = apps.get_model("chat_box", "Room") + seen = set() + + for room in Room.objects.all(): + pair = (room.user_one_id, room.user_two_id) + reverse_pair = (room.user_two_id, room.user_one_id) + + if pair in seen or reverse_pair in seen: + room.delete() + else: + seen.add(pair) + + +class Migration(migrations.Migration): + + dependencies = [ + ("chat_box", "0015_room_last_msg_time"), + ] + + operations = [ + migrations.RunPython(remove_duplicates), + migrations.AlterUniqueTogether( + name="room", + unique_together={("user_one", "user_two")}, + ), + ] diff --git a/chat_box/models.py b/chat_box/models.py index 476e861..6d86125 100644 --- a/chat_box/models.py +++ b/chat_box/models.py @@ -24,6 +24,7 @@ class Room(models.Model): class Meta: app_label = "chat_box" + unique_together = ("user_one", "user_two") @cached_property def _cached_info(self): diff --git a/judge/admin/organization.py b/judge/admin/organization.py index a6ccc8b..4ac7708 100644 --- a/judge/admin/organization.py +++ b/judge/admin/organization.py @@ -33,8 +33,6 @@ class OrganizationAdmin(VersionAdmin): "short_name", "is_open", "about", - "organization_image", - "logo_override_image", "slots", "registrant", "creation_date", diff --git a/judge/migrations/0191_deprecate_old_org_image.py b/judge/migrations/0191_deprecate_old_org_image.py new file mode 100644 index 0000000..76d76f3 --- /dev/null +++ b/judge/migrations/0191_deprecate_old_org_image.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.18 on 2024-08-22 03:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("judge", "0190_deprecate_old_notif_fields"), + ] + + operations = [ + migrations.RemoveField( + model_name="organization", + name="logo_override_image", + ), + ] diff --git a/judge/models/profile.py b/judge/models/profile.py index e601efc..4572b69 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -111,16 +111,6 @@ class Organization(models.Model): blank=True, ) organization_image = models.ImageField(upload_to=organization_image_path, null=True) - logo_override_image = models.CharField( - verbose_name=_("Logo override image"), - default="", - max_length=150, - blank=True, - help_text=_( - "This image will replace the default site logo for users " - "viewing the organization." - ), - ) def __contains__(self, item): if isinstance(item, int): diff --git a/judge/views/course.py b/judge/views/course.py index 8ab5c92..fbda7bd 100644 --- a/judge/views/course.py +++ b/judge/views/course.py @@ -48,8 +48,9 @@ def calculate_lessons_progress(profile, lessons): num_problems = len(problems) percentage = 0 for val in problem_points.values(): - score = val["case_points"] / val["case_total"] - percentage += score / num_problems + if val["case_total"] > 0: + score = val["case_points"] / val["case_total"] + percentage += score / num_problems res[lesson.id] = { "achieved_points": percentage * lesson.points, "percentage": percentage * 100, diff --git a/resources/common.js b/resources/common.js index 47ad467..4533703 100644 --- a/resources/common.js +++ b/resources/common.js @@ -538,6 +538,9 @@ function navigateTo(url, reload_container, force_new_page=false) { $(document).prop('title', $(data).filter('title').text()); renderKatex($(reload_container)[0]); + if ('DjangoPagedown' in window) { + DjangoPagedown.init(); + } onWindowReady(); registerNavList(); $('.xdsoft_datetimepicker').hide();