We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No borders, so neighboring bookings merge
repository.py:145
async def form_schedule(self, start_of_week: datetime.date) -> bytes: xbase = 48 # origin for x ybase = 73 # origin for y xsize = 175.5 # length of the rect by x-axis ysize = 32 # length of the rect by x-axis # Create a new image using PIL image = Image.open("src/repositories/bookings/schedule.jpg") draw = ImageDraw.Draw(image) lightGray = (211, 211, 211) lightBlack = (48, 54, 59) red = (255, 0, 0) fontSimple = ImageFont.truetype("src/repositories/bookings/open_sans.ttf", size=14) bookings = await self.get_bookings_for_week(start_of_week) for booking in bookings: day = booking.time_start.weekday() ylength = count_duration(booking.time_start, booking.time_end) x0 = xbase + xsize * day y0 = ybase + int(ysize * ((booking.time_start.hour - 7) + (booking.time_start.minute / 60.0))) x1 = x0 + xsize y1 = y0 + 31.5 * ylength draw.rounded_rectangle((x0, y0, x1, y1), 2, fill=lightGray) participant = await self.get_participant(booking.participant_id) alias = participant.alias max_alias_length: int = 10 if len(alias) > max_alias_length: alias = f"{alias[:max_alias_length]}..." caption = f"{alias} " # noinspection SqlAlchemyUnsafeQuery draw.text( (x0 + 2, (y0 + y1) / 2 - 9), text=f"{caption}{booking.time_start.strftime('%H:%M')}-{booking.time_end.strftime('%H:%M')}", fill=lightBlack, font=fontSimple, ) today = datetime.date.today() weekday = today.weekday() current = datetime.datetime.now() current_week = False if start_of_week <= current.date() <= start_of_week + timedelta(days=6): current_week = True # Drawing red line if 6 < current.hour < 23 and current_week: now_x0 = xbase + xsize * weekday now_y0 = ybase + int(ysize * ((current.hour - 7) + (current.minute / 60))) draw.rounded_rectangle((now_x0, now_y0, now_x0 + xsize, now_y0 + 2), 2, fill=red) await self.draw_week_numbers(draw, await self.is_start_of_week(start_of_week)) await self.draw_month_and_year(draw, current_week) image_stream = io.BytesIO() image.save(image_stream, format="png") val = image_stream.getvalue() image_stream.close() return val
The text was updated successfully, but these errors were encountered:
thisisfabrics
No branches or pull requests
Current situation
No borders, so neighboring bookings merge
Implementation
Related code
repository.py:145
The text was updated successfully, but these errors were encountered: