Skip to content

zimka/master -- initial #2

Closed
wants to merge 36 commits into from
Closed

zimka/master -- initial #2

wants to merge 36 commits into from

Conversation

martynovp
Copy link

No description provided.

models.py Outdated
if days_shift:
kwargs["days_shift"] = days_shift
course_shift_group, created_shift = CourseShiftGroup.objects.get_or_create(**kwargs)
return course_shift_group, created and created_shift
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нечитаемо. and в return - запутывает. return должен возвращать понятную штуку, без логики

@martynovp
Copy link
Author

Стоит логгировать в процессе стабилизации изменения и создание объектов

models.py Outdated

def delete(self, *args, **kwargs):
group = self.course_user_group
delete = super(CourseShiftGroup, self).delete(*args, **kwargs)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переменная с названием delete - это нехорошо

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вообще какой-то взрыв мозга тут происходит, метод нужно читаемым сделать

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А как тут лучше? Идея была, чтоб если мы удаляем ShiftGroup, соответствующий UserGroup тоже удаляли. Автоматически джанго умеет только наоборот, если ключ(UserGroup) удалят, то и ShiftGroup тоже

models.py Outdated
"""
all_memberships = cls.objects.filter(user=user)
course_membership = all_memberships.filter(course_shift_group__course_user_group__course_id=course_key)
membership = course_membership.first()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а возможна ситуация, когда course_membership - ов несколько?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

м.б. лучше просто
course_membership = ls.objects.filter(user=user, course_shift_group__course_user_group__course_id=course_key)
?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У юзера может быть много membership, а пара (юзер, course_key) должна иметь не более 1 membership

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я пока не понял, зачем фильтрацию в 2 этапа делать? результат же такой и будет

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

models.py Outdated
autostart_period_days = models.IntegerField(
default=28,
db_column='autostart_period_days',
help_text="Period of generated groups",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help_text надо поразвернутее написать

models.py Outdated

enroll_before_days = models.IntegerField(
default=14,
help_text="Days before start when student can enroll already"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и тут, желательно, с примерами

models.py Outdated
current_settings, created = cls.objects.get_or_create(course_key=course_key)
return current_settings

def update_shifts(self):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а зачем этот метод? что он делает и когда?

models.py Outdated
class CourseShiftPlannedRun(models.Model):
"""
Represents planned shift for course. Real plans are stored
in db and user only when new shifts are generated manually('is_autostart'=False)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

моя твоя не понимать

Copy link

@zimka zimka Sep 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А так?
Represents planned shift for course.
Plan can be launched, then it creates the shift and disappears.
For 'autostart' mode in settings mocked plans can be created:
they can be launched, but they are not stored in db and don't hit
it at plan deletion.

models.py Outdated
enroll_before_days = models.IntegerField(
default=14,
help_text="Days before shift start when student can enroll already."\
"E.g. if shift start 20.01.2020 and value is 5 shift will be available"\
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если уж мы пишем на англ, то дату стоит ставить либо 20 Jan 2020 либо 01/20/2020

models.py Outdated

class CourseShiftSettings(models.Model):
"""
Describes how should course shifts be run for
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Course Shift settings for start and due dates in the specific course run.

models.py Outdated
max_length=255,
db_index=True,
unique=True,
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

либо на строчку вверх, либо на 4 символа влево

models.py Outdated

is_shift_enabled = models.BooleanField(
default=False,
help_text="Is feature enabled for course"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True value if this feature enabled for the course run

manager.py Outdated
start_date=start_date,
days_shift=days_shift
)
return shift
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пустая строка тут нужна :)

@zimka zimka closed this Jun 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants