init commit
This commit is contained in:
0
hotels/__init__.py
Normal file
0
hotels/__init__.py
Normal file
BIN
hotels/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
hotels/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
hotels/__pycache__/admin.cpython-311.pyc
Normal file
BIN
hotels/__pycache__/admin.cpython-311.pyc
Normal file
Binary file not shown.
BIN
hotels/__pycache__/apps.cpython-311.pyc
Normal file
BIN
hotels/__pycache__/apps.cpython-311.pyc
Normal file
Binary file not shown.
BIN
hotels/__pycache__/models.cpython-311.pyc
Normal file
BIN
hotels/__pycache__/models.cpython-311.pyc
Normal file
Binary file not shown.
BIN
hotels/__pycache__/urls.cpython-311.pyc
Normal file
BIN
hotels/__pycache__/urls.cpython-311.pyc
Normal file
Binary file not shown.
17
hotels/admin.py
Normal file
17
hotels/admin.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from django.contrib import admin
|
||||
from .models import Hotel, UserHotel
|
||||
|
||||
@admin.register(Hotel)
|
||||
class HotelAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'pms_type', 'created_at')
|
||||
search_fields = ('name',)
|
||||
list_filter = ('pms_type',)
|
||||
ordering = ('-created_at',)
|
||||
|
||||
@admin.register(UserHotel)
|
||||
class UserHotelAdmin(admin.ModelAdmin):
|
||||
list_display = ('user', 'hotel')
|
||||
search_fields = ('user', 'hotel')
|
||||
list_filter = ('hotel',)
|
||||
ordering = ('-hotel',)
|
||||
|
||||
6
hotels/apps.py
Normal file
6
hotels/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class HotelsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'hotels'
|
||||
33
hotels/migrations/0001_initial.py
Normal file
33
hotels/migrations/0001_initial.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-05 23:39
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Hotel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255, verbose_name='Hotel Name')),
|
||||
('pms_type', models.CharField(choices=[('bnovo', 'Bnovo'), ('travelline', 'Travel Line')], max_length=50, verbose_name='PMS Type')),
|
||||
('api_key', models.CharField(blank=True, max_length=255, null=True, verbose_name='API Key')),
|
||||
('public_key', models.CharField(blank=True, max_length=255, null=True, verbose_name='Public Key')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='UserHotel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('hotel', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='hotels.hotel', verbose_name='Hotel')),
|
||||
],
|
||||
),
|
||||
]
|
||||
22
hotels/migrations/0002_initial.py
Normal file
22
hotels/migrations/0002_initial.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 5.1.4 on 2024-12-05 23:39
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('hotels', '0001_initial'),
|
||||
('users', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='userhotel',
|
||||
name='user',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.user', verbose_name='User'),
|
||||
),
|
||||
]
|
||||
0
hotels/migrations/__init__.py
Normal file
0
hotels/migrations/__init__.py
Normal file
BIN
hotels/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
BIN
hotels/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
Binary file not shown.
BIN
hotels/migrations/__pycache__/0002_initial.cpython-311.pyc
Normal file
BIN
hotels/migrations/__pycache__/0002_initial.cpython-311.pyc
Normal file
Binary file not shown.
BIN
hotels/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
hotels/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
23
hotels/models.py
Normal file
23
hotels/models.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.db import models
|
||||
from users.models import User
|
||||
|
||||
class Hotel(models.Model):
|
||||
name = models.CharField(max_length=255, verbose_name="Hotel Name")
|
||||
pms_type = models.CharField(
|
||||
max_length=50,
|
||||
choices=[('bnovo', 'Bnovo'), ('travelline', 'Travel Line')],
|
||||
verbose_name="PMS Type"
|
||||
)
|
||||
api_key = models.CharField(max_length=255, blank=True, null=True, verbose_name="API Key")
|
||||
public_key = models.CharField(max_length=255, blank=True, null=True, verbose_name="Public Key")
|
||||
created_at = models.DateTimeField(auto_now_add=True, verbose_name="Created At")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class UserHotel(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="User")
|
||||
hotel = models.ForeignKey(Hotel, on_delete=models.CASCADE, verbose_name="Hotel")
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.user.username} - {self.hotel.name}"
|
||||
3
hotels/tests.py
Normal file
3
hotels/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
0
hotels/urls.py
Normal file
0
hotels/urls.py
Normal file
3
hotels/views.py
Normal file
3
hotels/views.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user