Esempio n. 1
0
def create_zosia(commit=True, **kwargs):
    time = now()
    place, _ = Place.objects.get_or_create(name='Mieszko',
                                           address='FooBar@Katowice')
    defaults = {
        'active': False,
        'start_date': time,
        'place': place,
        'registration_start': time,
        'registration_end': timedelta_since_now(minutes=10),
        'rooming_start': timedelta_since_now(days=-1),
        'rooming_end': timedelta_since_now(days=1),
        'lecture_registration_start': time,
        'lecture_registration_end': timedelta_since_now(minutes=10),
        'price_accommodation': PRICE_ACCOMMODATION,
        'price_accommodation_breakfast': PRICE_BREAKFAST,
        'price_accommodation_dinner': PRICE_DINNER,
        'price_whole_day': PRICE_FULL,
        'price_base': PRICE_BASE,
        'price_transport': PRICE_TRANSPORT,
        'account_number': 'PL59 1090 2402 4156 9594 3379 3484',
        'account_owner': 'Joan Doe',
        'account_bank': 'SuperBank',
        'account_address': 'ul. Fajna 42, 51-109, Wrocław'
    }
    defaults.update(kwargs)
    zosia = Zosia(**defaults)
    if commit:
        zosia.save()
    return zosia
Esempio n. 2
0
def create_zosia(commit=True, **kwargs):
    time = now()
    place, _ = Place.objects.get_or_create(name='Mieszko',
                                           address='FooBar@Katowice')
    defaults = {
        'active': False,
        'start_date': time,
        'place': place,
        'registration_start': time,
        'registration_end': time,
        'rooming_start': timedelta_since_now(days=-1),
        'rooming_end': timedelta_since_now(days=1),
        'lecture_registration_start': time,
        'lecture_registration_end': time,
        'price_accomodation': PRICE_ACCOMODATION,
        'price_accomodation_breakfast': PRICE_BREAKFAST,
        'price_accomodation_dinner': PRICE_DINNER,
        'price_whole_day': PRICE_BONUS,
        'price_base': PRICE_BASE,
        'price_transport': PRICE_TRANSPORT,
        'account_number': '',
    }
    defaults.update(kwargs)
    zosia = Zosia(**defaults)
    if commit:
        zosia.save()
    return zosia
Esempio n. 3
0
def create_blogpost(author):
    data = {
        'title': lorem_ipsum.words(random.randint(5, 10)),
        'content': ''.join(lorem_ipsum.words(random.randint(10, 30)))[:500],
        'publication': now(),
        'author': author,
    }
    return BlogPost.objects.create(**data)
Esempio n. 4
0
def create_buses(zosia):
    time = now()

    Bus.objects.create(zosia=zosia,
                       time=time_point(time.year, time.month, time.day, 16),
                       capacity=45)
    Bus.objects.create(zosia=zosia,
                       time=time_point(time.year, time.month, time.day, 18),
                       capacity=45)
Esempio n. 5
0
    def test_can_user_choose_room_when_at_user_start_time(self):
        self.active.rooming_start = now()
        self.active.save()
        user_prefs = create_user_preferences(self.normal,
                                             self.active,
                                             payment_accepted=True,
                                             bonus_minutes=0)

        result = self.active.can_user_choose_room(user_prefs)

        self.assertTrue(result)
Esempio n. 6
0
def create_bus(commit=True, **override):
    zosia = override['zosia'] or create_zosia()
    defaults = {
        'capacity': 0,
        'departure_time': now(),
        'zosia': zosia,
    }
    defaults.update(**override)
    bus = Bus(**defaults)
    if commit:
        bus.save()
    return bus
Esempio n. 7
0
    def get_rooming_status(self, user_prefs, time=None):
        if time is None:
            time = now()

        user_start_time = user_prefs.rooming_start_time

        if user_start_time is None:
            return RoomingStatus.ROOMING_UNAVAILABLE

        if time < user_start_time:
            return RoomingStatus.BEFORE_ROOMING

        if time > self.rooming_end:
            return RoomingStatus.AFTER_ROOMING

        return RoomingStatus.ROOMING_PROGRESS
Esempio n. 8
0
def create_active_zosia(place, **kwargs):
    today = now()
    start_date = timedelta_since_now(days=350)
    start = today
    end = start_date
    data = {
        'active': True,
        'place': place,
        'registration_start': start,
        'registration_end': end,
        'start_date': start_date,
        'rooming_start': start,
        'rooming_end': end,
        'lecture_registration_start': start,
        'lecture_registration_end': end,
    }
    return create_zosia(**data)
Esempio n. 9
0
def create_past_zosia(place, **kwargs):
    start_date = random_date_before(now(), 400)
    registration_end = random_date_before(start_date, 20)
    registration_start = random_date_before(registration_end, 40)
    rooming_end = registration_end
    rooming_start = random_date_before(rooming_end, 12)
    data = {
        'place': place,
        'registration_start': registration_start,
        'registration_end': registration_end,
        'start_date': start_date,
        'rooming_start': rooming_start,
        'rooming_end': rooming_end,
        'lecture_registration_start': rooming_start,
        'lecture_registration_end': rooming_end,
    }
    return create_zosia(**data)
Esempio n. 10
0
 def setUp(self):
     time = now()
     place = Place.objects.create(name="Mieszko", address="foo")
     self.zosia = Zosia.objects.create(
         start_date=timedelta_since_now(days=1),
         active=True,
         place=place,
         price_accommodation=23,
         registration_end=time,
         registration_start=time,
         rooming_start=time,
         rooming_end=time,
         price_transport=0,
         lecture_registration_start=time,
         lecture_registration_end=time,
         price_accommodation_dinner=0,
         price_accommodation_breakfast=0,
         price_whole_day=0)
     self.user = create_user(0)
Esempio n. 11
0
 def is_registration_open(self):
     return self.registration_start <= now()
Esempio n. 12
0
def server_time():
    return now().strftime(DEFAULT_TIME_FORMAT)
Esempio n. 13
0
 def is_rooming_open(self):
     return now() <= self.rooming_end
Esempio n. 14
0
 def is_lectures_open(self):
     return self.lecture_registration_start <= now() <= \
            self.lecture_registration_end
Esempio n. 15
0
 def is_registration_over(self):
     return self.registration_end < now()
Esempio n. 16
0
 def is_expired(self):
     return self.expiration_date < now()
Esempio n. 17
0
 def is_rooming_open(self):
     return self.rooming_start - timedelta(minutes=MAX_BONUS_MINUTES) <= now()
Esempio n. 18
0
 def is_rooming_over(self):
     return self.rooming_end < now()