Skip to content

Refactor models and remove some unused things, add resource groups th…#116

Merged
Foosec merged 2 commits intomasterfrom
refactor_models
Dec 7, 2025
Merged

Refactor models and remove some unused things, add resource groups th…#116
Foosec merged 2 commits intomasterfrom
refactor_models

Conversation

@Foosec
Copy link
Copy Markdown
Collaborator

@Foosec Foosec commented Dec 7, 2025

…at can make resource selection mandatory and unique, add allocation trading and approval process

…at can make resource selection mandatory and unique, add allocation trading and approval process
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements a comprehensive allocation trading and approval system for the timetable application. The changes enable teachers to request time slot exchanges with colleagues, with an administrative approval workflow for managing these requests.

Key Changes:

  • Added trade request and approval workflow with multiple status states (OPEN, MATCHED, PENDING_APPROVAL, APPROVED, REJECTED, CANCELLED, EXPIRED)
  • Implemented views for creating, listing, viewing, canceling, and responding to trade requests
  • Added comprehensive test coverage for trade request functionality
  • Created template filters for formatting time, duration, and status displays
  • Uncommented SITE_ID = 1 in settings to enable multi-site functionality

Reviewed changes

Copilot reviewed 49 out of 52 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
uv.lock Complete dependency lock file added (1489 lines) for Python 3.13+
urnik_fri/settings_common.py Uncommented SITE_ID setting to enable Django sites framework
timetable/views.py Added 11 new views for trade request lifecycle management (736 lines added)
timetable/urls.py Removed deprecated teacher preferences URL, added 8 trade request URLs
timetable/tests.py Added comprehensive test suite with 609 lines covering models, forms, and views
timetable/templatetags/timetable_extras.py Added 8 utility filters for formatting and display
timetable/templates/timetable/trade_requests/*.html Added 3 templates for rejection confirmation, request listing, and detail views
timetable/models/tags.py New Tag model for categorizing teachers, activities, and groups
timetable/models/classrooms.py New classroom-related models extracted to separate file
timetable/management/commands/init.py Empty init file for management commands

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread timetable/models/activities.py Outdated
Comment on lines +190 to +192
# class ActivityPercentage(models.Model):
# teacher = models.ForeignKey('Teacher')
# activity = models.ForeignKey('Activity')
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

This comment appears to contain commented-out code.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment thread timetable/tests.py
from timetable.forms import TradeRequestForm

# Create another allocation for the same teacher at different time
other_allocation = Allocation.objects.create(
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Variable other_allocation is not used.

Copilot uses AI. Check for mistakes.
Comment thread timetable/views.py Outdated
# Get timetable if slug provided (for context)
timetable = None
if timetable_slug:
timetable = get_object_or_404(Timetable, slug=timetable_slug)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Variable timetable is not used.

Copilot uses AI. Check for mistakes.
Comment thread timetable/views.py Outdated
# Get timetable if slug provided (for redirect context)
timetable = None
if timetable_slug:
timetable = get_object_or_404(Timetable, slug=timetable_slug)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Variable timetable is not used.

Copilot uses AI. Check for mistakes.
Comment thread timetable/views.py Outdated

# Create a match between the two requests
try:
trade_match = original_request.create_match(counter_request)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Variable trade_match is not used.

Copilot uses AI. Check for mistakes.
Comment thread friprosveta/views.py Outdated
Comment on lines +42 to +51
from timetable.views import (
trade_request_list,
my_trade_requests,
create_trade_request,
trade_request_detail,
cancel_trade_request,
respond_to_trade_request,
reject_trade_request,
trade_match_queue,
)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Import of 'trade_request_list' is not used.
Import of 'my_trade_requests' is not used.
Import of 'create_trade_request' is not used.
Import of 'trade_request_detail' is not used.
Import of 'cancel_trade_request' is not used.
Import of 'respond_to_trade_request' is not used.
Import of 'reject_trade_request' is not used.
Import of 'trade_match_queue' is not used.

Suggested change
from timetable.views import (
trade_request_list,
my_trade_requests,
create_trade_request,
trade_request_detail,
cancel_trade_request,
respond_to_trade_request,
reject_trade_request,
trade_match_queue,
)

Copilot uses AI. Check for mistakes.
Comment thread timetable/views.py
try:
trade_request = TradeRequest.objects.get(pk=request_id)
timetable_slug = trade_request.offered_allocation.timetable.slug
except:
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Except block directly handles BaseException.

Copilot uses AI. Check for mistakes.
Comment thread timetable/views.py
try:
trade_match = TradeMatch.objects.get(pk=match_id)
timetable_slug = trade_match.request_1.offered_allocation.timetable.slug
except:
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Except block directly handles BaseException.

Copilot uses AI. Check for mistakes.
Comment thread timetable/views.py
try:
trade_request = TradeRequest.objects.get(pk=request_id)
timetable_slug = trade_request.offered_allocation.timetable.slug
except:
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.
Comment thread timetable/views.py
try:
trade_match = TradeMatch.objects.get(pk=match_id)
timetable_slug = trade_match.request_1.offered_allocation.timetable.slug
except:
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Copilot AI commented Dec 7, 2025

@Foosec I've opened a new pull request, #117, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 52 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread timetable/views.py
try:
trade_request = TradeRequest.objects.get(pk=request_id)
timetable_slug = trade_request.offered_allocation.timetable.slug
except:
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Except block directly handles BaseException.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment thread timetable/views.py
try:
trade_match = TradeMatch.objects.get(pk=match_id)
timetable_slug = trade_match.request_1.offered_allocation.timetable.slug
except:
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

Except block directly handles BaseException.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment thread timetable/views.py
try:
trade_request = TradeRequest.objects.get(pk=request_id)
timetable_slug = trade_request.offered_allocation.timetable.slug
except:
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Comment thread timetable/views.py
try:
trade_match = TradeMatch.objects.get(pk=match_id)
timetable_slug = trade_match.request_1.offered_allocation.timetable.slug
except:
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown

Copilot AI commented Dec 7, 2025

@Foosec I've opened a new pull request, #118, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown

Copilot AI commented Dec 7, 2025

@Foosec I've opened a new pull request, #119, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown

Copilot AI commented Dec 7, 2025

@Foosec I've opened a new pull request, #120, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown

Copilot AI commented Dec 7, 2025

@Foosec I've opened a new pull request, #121, to work on those changes. Once the pull request is ready, I'll request review from you.

@Foosec Foosec merged commit 6c7f268 into master Dec 7, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants