Skip to content

Commit

Permalink
Merge branch 'dev' into 294-crear-llistat-de-ofertes-per-administrador
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanca192001 authored Jun 12, 2024
2 parents 627fa6c + b325cd2 commit 729ebfa
Show file tree
Hide file tree
Showing 34 changed files with 1,140 additions and 416 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name: Playwright Tests
on:
push:
branches: [ main, master, dev ]
pull_request:
branches: [ main, master, dev ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Ensure browsers are installed
run: python manage.py runserver & python -m playwright install --with-deps
- name: Run your tests
run: pytest --tracing=retain-on-failure
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-traces
path: test-results/
#name: Playwright Tests
#on:
# push:
# branches: [ main, master, dev ]
# pull_request:
# branches: [ main, master, dev ]
#jobs:
# test:
# timeout-minutes: 60
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.11'
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# - name: Ensure browsers are installed
# run: python manage.py runserver & python -m playwright install --with-deps
# - name: Run your tests
# run: pytest --tracing=retain-on-failure
# - uses: actions/upload-artifact@v4
# if: ${{ !cancelled() }}
# with:
# name: playwright-traces
# path: test-results/
14 changes: 12 additions & 2 deletions Billing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from Billing.forms import PromotionForm, CouponForm
from Billing.models import Promotion, Coupon
from Reception.models import RoomReservation
from Restaurant.models import RestaurantReservation


# Create your views here.
Expand All @@ -12,7 +14,6 @@ def list_offers(request):
return render(request, 'billing/list_offers.html', {'ofertas': promotions, 'cupones': coupons})
return redirect('home')


def list_coupons(request):
if request.user.has_perm('accountant'):
coupons = Coupon.objects.all()
Expand Down Expand Up @@ -52,7 +53,6 @@ def edit_coupon(request):
return redirect('list_coupons')
return redirect('home')


def create_offer(request):
if request.user.has_perm('accountant') and request.method == 'POST':
form = PromotionForm(request.POST, request.FILES)
Expand All @@ -61,6 +61,11 @@ def create_offer(request):
return redirect('list_offers')
return redirect('home')

def list_restaurant_and_room(request):
if request.user.has_perm('accountant'):
reservations = RoomReservation.objects.filter(guest_leaved=True)
return render(request, 'billing/list_reservations.html', {'reservas': reservations})


def edit_offer(request):
if request.user.has_perm('accountant'):
Expand All @@ -83,3 +88,8 @@ def delete_offer(request, offer_id):
promotion.delete()
return redirect('list_offers')
return redirect('home')

def details_reservation(request, reservation_id):
room_reservation = get_object_or_404(RoomReservation, pk=reservation_id)
restaurant_reservations = RestaurantReservation.objects.filter(room_reservation=room_reservation)
return render(request, 'billing/details_reservation.html', {'room_reservation': room_reservation, 'restaurant_reservations': restaurant_reservations})
7 changes: 4 additions & 3 deletions PlayWright/Reception/test_book_logged.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
from playwright.sync_api import Page, expect
import time


def test_book_logged(page: Page) -> None:
Expand All @@ -11,10 +12,10 @@ def test_book_logged(page: Page) -> None:
page.get_by_label("Contraseña").fill("admin")
page.get_by_role("main").get_by_role("button", name="Log in").click()
page.get_by_role("link", name="Reservar").click()
page.get_by_placeholder("Fecha de Entrada ").fill("2024-10-24")
page.get_by_placeholder("Fecha de Salida").fill("2024-10-26")
time.sleep(1)
page.get_by_placeholder("Fecha de Entrada ").fill("2024-12-12")
page.get_by_placeholder("Fecha de Salida").fill("2024-12-25")
page.get_by_placeholder("Número de Huéspedes").click()
page.get_by_placeholder("Número de Huéspedes").fill("2")
page.get_by_text("Precio Habitación: 0 Importe").click()
page.get_by_role("button", name="Reservar").click()
#expect(page.get_by_role("button", name="Descargar Comprobante")).to_be_visible()
22 changes: 6 additions & 16 deletions PlayWright/Reception/test_book_no_logged.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import re
from playwright.sync_api import Page, expect

import time

def test_book_no_logged(page: Page) -> None:
page.goto("http://localhost:8000/")
page.get_by_role("link", name="Reservar").click()
page.get_by_placeholder("DNI").click()
page.get_by_placeholder("DNI").fill("12312312a")
page.get_by_placeholder("DNI").press("Tab")
page.get_by_placeholder("Nombre").fill("test")
page.get_by_placeholder("Nombre").press("Tab")
page.get_by_placeholder("Apellidos").fill("test")
page.get_by_placeholder("Apellidos").press("Tab")
page.get_by_placeholder("Correo Electrónico").fill("[email protected]")
page.get_by_placeholder("Correo Electrónico").press("Tab")
page.get_by_placeholder("Teléfono").fill("123123123")
page.get_by_placeholder("Fecha de Entrada ").fill("2024-10-22")
page.get_by_placeholder("Fecha de Salida").fill("2024-10-24")
time.sleep(1)
page.get_by_placeholder("Fecha de Entrada ").fill("2024-12-12")
page.get_by_placeholder("Fecha de Salida").fill("2024-12-25")
page.get_by_placeholder("Número de Huéspedes").click()
page.get_by_placeholder("Número de Huéspedes").fill("3")
page.get_by_text("Volver Reservar DNI Nombre").click()
page.get_by_placeholder("Número de Huéspedes").fill("2")
page.get_by_role("button", name="Reservar").click()
#expect(page.get_by_role("button", name="Descargar Comprobante")).to_be_visible()
# expect(page.get_by_role("button", name="Descargar Comprobante")).to_be_visible()
3 changes: 1 addition & 2 deletions PlayWright/Reception/test_check_menu_in_receptionist_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ def test_check_menu_in_receptionist_role(page: Page) -> None:
page.goto("http://localhost:8000/")
page.get_by_role("button", name="Log in").click()
page.get_by_label("Usuario").click()
page.get_by_label("Usuario").fill("receptionuser")
page.get_by_label("Usuario").fill("reception")
page.get_by_label("Contraseña").click()
page.get_by_label("Contraseña").fill("admin")
page.get_by_label("Contraseña").press("Enter")
expect(page.get_by_role("button", name="Recepcion")).to_be_visible()
10 changes: 9 additions & 1 deletion PlayWright/Reception/test_go_booking_from_rooms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import re
from playwright.sync_api import Page, expect
import time



def test_go_booking_from_rooms(page: Page) -> None:
page.goto("http://localhost:8000/")
page.get_by_role("link", name="Habitaciones", exact=True).click()
page.get_by_role("link", name="Reservar").nth(1).click()
page.get_by_placeholder("DNI").click()
time.sleep(1)
page.get_by_placeholder("Fecha de Entrada ").fill("2024-12-12")
page.get_by_placeholder("Fecha de Entrada ").press("Enter")
page.get_by_placeholder("Fecha de Salida").fill("2024-12-25")
page.get_by_placeholder("Número de Huéspedes").click()
page.get_by_placeholder("Número de Huéspedes").fill("2")
page.get_by_role("button", name="Reservar").click()
14 changes: 14 additions & 0 deletions Reception/management/commands/delete_after_2_year.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.core.management.base import BaseCommand
from django.utils import timezone

from Reception.models import RoomReservation


class Command(BaseCommand):
help = 'Deletes room reservations older than 2 years'

def handle(self, *args, **kwargs):
two_years_ago = timezone.now() - timezone.timedelta(days=365 * 2)
old_reservations = RoomReservation.objects.filter(guest_checkout__lt=two_years_ago)
old_reservations.delete()
self.stdout.write(self.style.SUCCESS('Deleted room reservations where checkout date is older than 2 years.'))
2 changes: 1 addition & 1 deletion Reception/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RoomReservation(models.Model):
guest_is_here = models.BooleanField(default=False)
guest_leaved = models.BooleanField(default=False)
guests_number = models.IntegerField(default=0)
price = models.DecimalField( max_digits=100, decimal_places=2)
price = models.DecimalField(max_digits=100, decimal_places=2)
room_number = models.ForeignKey(Room, on_delete=models.CASCADE)
room_is_payed = models.BooleanField(default=False)

Expand Down
Loading

0 comments on commit 729ebfa

Please sign in to comment.