From a9f1e4553bdc1d6685fec9f210232f7ee3678e4c Mon Sep 17 00:00:00 2001 From: Vidir Valberg Gudmundsson Date: Sat, 26 Aug 2017 03:48:02 +0200 Subject: [PATCH] Initial bar app. --- src/bar/__init__.py | 0 src/bar/admin.py | 16 +++++++++ src/bar/apps.py | 7 ++++ src/bar/migrations/0001_initial.py | 45 +++++++++++++++++++++++++ src/bar/migrations/__init__.py | 0 src/bar/models.py | 21 ++++++++++++ src/bar/templates/bar_menu.html | 54 ++++++++++++++++++++++++++++++ src/bar/views.py | 9 +++++ src/bornhack/settings.py | 1 + src/bornhack/urls.py | 7 ++++ src/static_src/css/bornhack.css | 22 ++++++++++++ 11 files changed, 182 insertions(+) create mode 100644 src/bar/__init__.py create mode 100644 src/bar/admin.py create mode 100644 src/bar/apps.py create mode 100644 src/bar/migrations/0001_initial.py create mode 100644 src/bar/migrations/__init__.py create mode 100644 src/bar/models.py create mode 100644 src/bar/templates/bar_menu.html create mode 100644 src/bar/views.py diff --git a/src/bar/__init__.py b/src/bar/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/bar/admin.py b/src/bar/admin.py new file mode 100644 index 00000000..337ee768 --- /dev/null +++ b/src/bar/admin.py @@ -0,0 +1,16 @@ +from django.contrib import admin + +from .models import ProductCategory, Product + + +@admin.register(ProductCategory) +class ProductCategoryAdmin(admin.ModelAdmin): + pass + + +@admin.register(Product) +class ProductAdmin(admin.ModelAdmin): + list_display = ['name', 'price', 'category', 'in_stock'] + list_editable = ['in_stock'] + + diff --git a/src/bar/apps.py b/src/bar/apps.py new file mode 100644 index 00000000..7a6c111b --- /dev/null +++ b/src/bar/apps.py @@ -0,0 +1,7 @@ + + +from django.apps import AppConfig + + +class BarConfig(AppConfig): + name = 'bar' diff --git a/src/bar/migrations/0001_initial.py b/src/bar/migrations/0001_initial.py new file mode 100644 index 00000000..3712a867 --- /dev/null +++ b/src/bar/migrations/0001_initial.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-08-25 23:28 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('camps', '0022_camp_colour'), + ] + + operations = [ + migrations.CreateModel( + name='Product', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('price', models.IntegerField()), + ('in_stock', models.BooleanField(default=True)), + ], + ), + migrations.CreateModel( + name='ProductCategory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('name', models.CharField(max_length=255)), + ('camp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='camps.Camp')), + ], + options={ + 'abstract': False, + }, + ), + migrations.AddField( + model_name='product', + name='category', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bar.ProductCategory'), + ), + ] diff --git a/src/bar/migrations/__init__.py b/src/bar/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/bar/models.py b/src/bar/models.py new file mode 100644 index 00000000..238b3520 --- /dev/null +++ b/src/bar/models.py @@ -0,0 +1,21 @@ +from django.db import models + +from utils.models import CampRelatedModel + + +class ProductCategory(CampRelatedModel): + name = models.CharField(max_length=255) + camp = models.ForeignKey('camps.Camp') + + def __str__(self): + return self.name + + +class Product(models.Model): + name = models.CharField(max_length=255) + price = models.IntegerField() + category = models.ForeignKey(ProductCategory, related_name="products") + in_stock = models.BooleanField(default=True) + + def __str__(self): + return self.name diff --git a/src/bar/templates/bar_menu.html b/src/bar/templates/bar_menu.html new file mode 100644 index 00000000..59e0040f --- /dev/null +++ b/src/bar/templates/bar_menu.html @@ -0,0 +1,54 @@ +{% load static from staticfiles %} +{% load bootstrap3 %} +{% load menubutton %} +{% static "" as baseurl %} + + + + + + + + + {% block title %}BornHack{% endblock %} + + + + + + + + + + + {% bootstrap_javascript jquery=1 %} + + + + + + + + + + + + +{% block content %} + +
+ {% for category in categories %} +

{{ category.name }}

+ + {% for product in category.products.all %} +
+

{{ product.name }}

+

{{ product.price }} HAX

+
+ {% endfor %} + + {% endfor %} +
+{% endblock %} + + diff --git a/src/bar/views.py b/src/bar/views.py new file mode 100644 index 00000000..b87306f4 --- /dev/null +++ b/src/bar/views.py @@ -0,0 +1,9 @@ +from .models import ProductCategory, Product + +from django.views.generic import ListView + + +class MenuView(ListView): + model = ProductCategory + template_name = "bar_menu.html" + context_object_name = "categories" diff --git a/src/bornhack/settings.py b/src/bornhack/settings.py index 1ea67e0d..699b7956 100644 --- a/src/bornhack/settings.py +++ b/src/bornhack/settings.py @@ -43,6 +43,7 @@ INSTALLED_APPS = [ 'teams', 'people', 'tickets', + 'bar', 'allauth', 'allauth.account', diff --git a/src/bornhack/urls.py b/src/bornhack/urls.py index 0c09a5b6..6178d8b8 100644 --- a/src/bornhack/urls.py +++ b/src/bornhack/urls.py @@ -13,6 +13,7 @@ from sponsors.views import * from teams.views import * from people.views import * from tickets.views import ShopTicketListView +from bar.views import MenuView urlpatterns = [ url( @@ -263,6 +264,12 @@ urlpatterns = [ name='sponsors' ), + url( + r'^bar/menu$', + MenuView.as_view(), + name='menu' + ), + url( r'^villages/', include([ url( diff --git a/src/static_src/css/bornhack.css b/src/static_src/css/bornhack.css index 84b3c188..c4d50766 100644 --- a/src/static_src/css/bornhack.css +++ b/src/static_src/css/bornhack.css @@ -274,3 +274,25 @@ footer { .sponsor .caption { text-align: center; } + +.bar-row { + -moz-column-width: 300px; + -webkit-column-width: 300px; + column-width: 300px; +} + +.bar-product { + display: flex; + justify-content: flex-start; + border-bottom: 1px solid lightgrey; +} + +.bar-product .name { + width: 900px; +} + +.bar-product .price { + width: 300px; +} + +