Fix minor bugs and improve some model fields
This commit is contained in:
parent
f98549e92d
commit
a42bae51f7
7 changed files with 56 additions and 14 deletions
32
chat_box/migrations/0016_alter_room_unique_together.py
Normal file
32
chat_box/migrations/0016_alter_room_unique_together.py
Normal file
|
@ -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")},
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
|
@ -33,8 +33,6 @@ class OrganizationAdmin(VersionAdmin):
|
|||
"short_name",
|
||||
"is_open",
|
||||
"about",
|
||||
"organization_image",
|
||||
"logo_override_image",
|
||||
"slots",
|
||||
"registrant",
|
||||
"creation_date",
|
||||
|
|
17
judge/migrations/0191_deprecate_old_org_image.py
Normal file
17
judge/migrations/0191_deprecate_old_org_image.py
Normal file
|
@ -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",
|
||||
),
|
||||
]
|
|
@ -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):
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue