Exemplo n.º 1
0
class Attribution(SerializableModel):
    external_id = models.CharField(max_length=100,
                                   blank=True,
                                   null=True,
                                   db_index=True)
    changed = models.DateTimeField(null=True, auto_now=True)
    start_date = models.DateField(auto_now=False,
                                  blank=True,
                                  null=True,
                                  auto_now_add=False)
    end_date = models.DateField(auto_now=False,
                                blank=True,
                                null=True,
                                auto_now_add=False)
    start_year = models.IntegerField(blank=True, null=True)
    end_year = models.IntegerField(blank=True, null=True)
    function = models.CharField(max_length=35,
                                blank=True,
                                null=True,
                                choices=Functions.choices(),
                                db_index=True)
    learning_unit_year = models.ForeignKey('base.LearningUnitYear',
                                           on_delete=models.CASCADE)
    tutor = models.ForeignKey('base.Tutor', on_delete=models.CASCADE)
    score_responsible = models.BooleanField(default=False)
    summary_responsible = models.BooleanField(default=False)

    def __str__(self):
        return u"%s - %s" % (self.tutor.person, self.get_function_display())

    @property
    def duration(self):
        if self.start_year and self.end_year:
            return (self.end_year - self.start_year) + 1
        return None
Exemplo n.º 2
0
class AttributionNew(models.Model):
    external_id = models.CharField(max_length=100,
                                   blank=True,
                                   null=True,
                                   db_index=True)
    changed = models.DateTimeField(null=True, auto_now=True)
    learning_container_year = models.ForeignKey('base.LearningContainerYear')
    tutor = models.ForeignKey('base.Tutor')
    function = models.CharField(max_length=35,
                                choices=Functions.choices(),
                                db_index=True,
                                verbose_name=_("Function"))
    start_date = models.DateField(blank=True, null=True)
    end_date = models.DateField(blank=True, null=True)
    start_year = models.IntegerField(blank=True,
                                     null=True,
                                     verbose_name=_("Start"))
    end_year = models.IntegerField(blank=True, null=True)
    score_responsible = models.BooleanField(default=False)
    substitute = models.ForeignKey('base.Person', blank=True, null=True)

    def __str__(self):
        return u"%s - %s" % (self.tutor.person, self.function)

    @property
    def duration(self):
        if self.start_year and self.end_year:
            return (self.end_year - self.start_year) + 1
        return None
Exemplo n.º 3
0
class TutorApplication(models.Model):
    external_id = models.CharField(max_length=100,
                                   blank=True,
                                   null=True,
                                   db_index=True)
    changed = models.DateTimeField(null=True, auto_now=True)
    learning_container_year = models.ForeignKey('base.LearningContainerYear')
    tutor = models.ForeignKey('base.Tutor')
    function = models.CharField(max_length=35,
                                blank=True,
                                null=True,
                                choices=Functions.choices(),
                                db_index=True)
    volume_lecturing = models.DecimalField(max_digits=6,
                                           decimal_places=1,
                                           blank=True,
                                           null=True)
    volume_pratical_exercice = models.DecimalField(max_digits=6,
                                                   decimal_places=1,
                                                   blank=True,
                                                   null=True)
    remark = models.TextField(blank=True, null=True)
    course_summary = models.TextField(blank=True, null=True)
    last_changed = models.DateTimeField(null=True)

    def __str__(self):
        return u"%s - %s" % (self.tutor, self.function)
Exemplo n.º 4
0
    def __init__(self, *args, **kwargs):
        self.learning_unit_year = kwargs.pop("learning_unit_year")
        super().__init__(*args, **kwargs)

        if self.learning_unit_year.is_for_faculty_or_partim():
            del self.fields["start_year"]
            del self.fields["duration"]
            self.fields["function"].choices = Functions.choices_without_professor()
Exemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        self.learning_unit_year = kwargs.pop("learning_unit_year")
        super().__init__(*args, **kwargs)

        if self.learning_unit_year.learning_container_year.container_type != learning_container_year_types.COURSE or \
                self.learning_unit_year.is_partim():
            del self.fields["start_year"]
            del self.fields["duration"]
            self.fields[
                "function"].choices = Functions.choices_without_professor()
Exemplo n.º 6
0
class AttributionNewFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = "attribution.AttributionNew"

    external_id = factory.fuzzy.FuzzyText(length=10, chars=string.digits)
    changed = fake.date_time_this_decade(before_now=True, after_now=True, tzinfo=get_tzinfo())
    start_date = None
    end_date = None
    start_year = None
    end_year = None
    function = factory.Iterator(Functions.choices(), getter=lambda c: c[0])
    tutor = factory.SubFactory(TutorFactory)
    score_responsible = False
    learning_container_year = factory.SubFactory(LearningContainerYearFactory)
Exemplo n.º 7
0
class TutorApplicationFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = "attribution.TutorApplication"

    external_id = factory.fuzzy.FuzzyText(length=10, chars=string.digits)
    changed = fake.date_time_this_decade(before_now=True,
                                         after_now=True,
                                         tzinfo=get_tzinfo())
    function = factory.Iterator(Functions.choices(), getter=lambda c: c[0])
    tutor = factory.SubFactory(TutorFactory)
    learning_container_year = factory.SubFactory(LearningContainerYearFactory)
    volume_lecturing = factory.fuzzy.FuzzyDecimal(99)
    volume_pratical_exercice = factory.fuzzy.FuzzyDecimal(99)
    last_changed = factory.fuzzy.FuzzyNaiveDateTime(
        datetime.datetime(2016, 1, 1), datetime.datetime(2017, 3, 1))