-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from CodeHive-Solutions/dev
Remove brothers image
- Loading branch information
Showing
14 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class CarouselImageConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'carousel_image' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 5.0.7 on 2024-09-09 16:51 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Banner', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(max_length=100)), | ||
('link', models.URLField(blank=True, null=True)), | ||
('active', models.BooleanField(default=True)), | ||
('image', models.ImageField(upload_to='carousel_images/banners/')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.db import models | ||
|
||
|
||
class Banner(models.Model): | ||
title = models.CharField(max_length=100) | ||
link = models.URLField(blank=True, null=True) | ||
active = models.BooleanField(default=True) | ||
image = models.ImageField(upload_to="carousel_images/banners/") | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return self.title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from rest_framework import serializers | ||
from .models import Banner | ||
|
||
|
||
class BannerSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Banner | ||
fields = "__all__" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from services.tests import BaseTestCase | ||
from django.urls import reverse | ||
from .models import Banner | ||
|
||
|
||
# Create your tests here. | ||
class BannerTestCase(BaseTestCase): | ||
def setUp(self): | ||
self.banner = Banner.objects.create( | ||
title="Test Banner", | ||
link="https://www.google.com", | ||
active=True, | ||
image="carousel_images/banners/test.jpg", | ||
) | ||
|
||
def test_get_banner(self): | ||
banner_2 = self.banner | ||
response = self.client.get(reverse("banners-list")) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(len(response.data), 2) | ||
self.assertEqual(response.data[0]["title"], "Test Banner") | ||
self.assertEqual(response.data[0]["link"], "https://www.google.com") | ||
self.assertEqual(response.data[0]["active"], True) | ||
self.assertEqual(response.data[0]["image"], "carousel_images/banners/test.jpg") | ||
|
||
def test_delete_banner(self): | ||
response = self.client.delete(reverse("banners-detail", args=[self.banner.id])) | ||
self.assertEqual(response.status_code, 204) | ||
self.assertEqual(Banner.objects.count(), 1) | ||
self.assertEqual(Banner.objects.filter(active=True).count(), 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from rest_framework.routers import DefaultRouter | ||
from .views import BannerViewSet | ||
|
||
router = DefaultRouter() | ||
|
||
router.register(r"banners", BannerViewSet, basename="banners") | ||
|
||
urlpatterns = router.urls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from rest_framework import viewsets | ||
from rest_framework import status | ||
from rest_framework.response import Response | ||
from .models import Banner | ||
from .serializer import BannerSerializer | ||
|
||
|
||
class BannerViewSet(viewsets.ModelViewSet): | ||
queryset = Banner.objects.filter(active=True) | ||
serializer_class = BannerSerializer | ||
|
||
def destroy(self, request, *args, **kwargs): | ||
instance = self.get_object() | ||
instance.active = False | ||
instance.save() | ||
return Response(status=status.HTTP_204_NO_CONTENT) |
18 changes: 18 additions & 0 deletions
18
INSIGHTSAPI/vacation/migrations/0017_alter_vacationrequest_status.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.0.7 on 2024-09-09 16:51 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('vacation', '0016_vacationrequest_sat_is_working'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='vacationrequest', | ||
name='status', | ||
field=models.CharField(choices=[('PENDIENTE', 'PENDIENTE'), ('APROBADA', 'APROBADA'), ('RECHAZADA', 'RECHAZADA'), ('CANCELADA', 'CANCELADA')], default='PENDIENTE', max_length=100), | ||
), | ||
] |
Binary file not shown.