Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update demo site for development #17

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
53fd54a
Initial codebase changes
nickmoreton Sep 1, 2024
8b7bd17
Load longclaw from git repository
nickmoreton Sep 1, 2024
0366a4c
Update python version
nickmoreton Sep 1, 2024
c29d780
Add docker-compose.yml for development
nickmoreton Sep 1, 2024
df4de22
Ignore the root static directory
nickmoreton Sep 1, 2024
cdfb85e
Update styles
nickmoreton Sep 1, 2024
3a1cbc9
Add google fonts
nickmoreton Sep 1, 2024
21f6b6c
Ignore the root media directory
nickmoreton Sep 1, 2024
e82b6f3
Remove /media
nickmoreton Sep 1, 2024
9cb9f21
Docker development improvements
nickmoreton Sep 1, 2024
6ef5b54
Update README.md
nickmoreton Sep 1, 2024
2ae6704
Sort some settings
nickmoreton Sep 2, 2024
401722f
use latest node
nickmoreton Sep 2, 2024
9d48234
Add some base styles and example scripts
nickmoreton Sep 2, 2024
fd6d9d4
Initial styling
nickmoreton Sep 2, 2024
85650f3
Initial dev settings
nickmoreton Sep 2, 2024
e3fd9cf
Make basket page better
nickmoreton Sep 2, 2024
59c2212
Adjust templates
nickmoreton Sep 2, 2024
37222b8
Modal ins't available on all pages
nickmoreton Sep 2, 2024
d2a8ff7
Product index initial update
nickmoreton Sep 2, 2024
c2d222f
Product page breaks for the basket_tags
nickmoreton Sep 2, 2024
d659dcb
Nicer header nav
nickmoreton Sep 2, 2024
e1125d3
Should need these any longer
nickmoreton Sep 2, 2024
e868e8a
Make some docker improvements incl.
nickmoreton Sep 3, 2024
1618653
Initial fixtures
nickmoreton Sep 3, 2024
540178c
Some refinements to the UI
nickmoreton Sep 3, 2024
9fea91c
image fixture
nickmoreton Sep 3, 2024
a4cd353
Update readme a little
nickmoreton Sep 3, 2024
d7350df
Small styling adjustment
nickmoreton Sep 3, 2024
3235a4c
Update fixtures
nickmoreton Sep 3, 2024
5bfe616
Enable delete basket item functionality
nickmoreton Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ docs/_build
webpack-stats.json
*bundle.js*

static/
/static
/media
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
38 changes: 23 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
FROM python:3.6
FROM python:3.9

WORKDIR opt/deploy/
RUN mkdir nvm
ENV NVM_DIR /opt/deploy/nvm
RUN useradd longclaw_bakery --create-home && mkdir /app && chown -R longclaw_bakery /app

# Install nvm with node and npm
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install --lts\
&& nvm use --lts
WORKDIR /app

ADD . .
ENV PYTHONUNBUFFERED=1 \
DJANGO_SETTINGS_MODULE=longclaw_bakery.settings.production \
PORT=8000

EXPOSE 8000

RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
build-essential \
libpq-dev \
curl \
git \
&& apt-get autoremove && rm -rf /var/lib/apt/lists/*


COPY requirements.txt .

RUN pip install -U pip
RUN pip install -r requirements.txt
RUN python manage.py makemigrations catalog home \
&& python manage.py migrate \
&& python manage.py loadcountries

EXPOSE 8000
CMD python manage.py runserver 0.0.0.0:8000
USER longclaw_bakery
ADD . .

CMD tail -f /dev/null
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
destroy:
@echo "Destroying the environment..."
docker compose down -v

build:
@echo "Building the environment..."
docker compose build

up:
@echo "Starting the environment..."
docker compose up -d

exec:
@echo "Accessing the container..."
docker compose exec web bash

destroy:
@echo "Destroying the environment..."
docker compose down -v

dev:
@echo "Starting the development environment..."
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d
docker compose exec web bash -c "pip install -e /longclaw"
docker compose exec web python manage.py migrate
docker compose exec web python manage.py loadcountries

run-dev:
@echo "Running the development environment..."
docker compose exec web python manage.py runserver 0.0.0.0:8000

loaddata:
@echo "Loading data..."
docker compose exec web python manage.py loaddata fixtures.json
docker compose exec web bash -c "mkdir -p media/original_images"
docker compose exec web bash -c "cp -r media_fixtures/* media/original_images"

dumpdata:
@echo "Dumping data..."
docker compose exec web python manage.py dumpdata --natural-foreign --indent 2 \
-e contenttypes -e auth.permission \
-e wagtailcore.groupcollectionpermission \
-e wagtailcore.grouppagepermission -e wagtailimages.rendition \
-e sessions -e basket.basketitem -e shipping.country > fixtures.json
82 changes: 72 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,89 @@
Longclaw Demo
=============================
# Longclaw Demo

Demo shop for Longclaw

This example shop is intended to show the capabilities of longclaw.

When creating your own shop, I recommend starting afresh using the `longclaw start` command, rather than forking this project.

Quickstart
----------
## Quickstart

Clone this repository
```bash
git clone https://github.com/JamesRamm/longclaw_demo.git
cd longclaw_demo
```
$ git clone https://github.com/JamesRamm/longclaw_demo.git
$ cd longclaw_demo
```

Build the docker image

```bash
docker compose build
```
$ docker build -t longclaw-demo .

Use one of the options below to start the container

**Note:** Untill the package rebuild has been released, you will need to use option 2 to run the demo locally.

### Option 1

#### Running the demo locally, using the published PyPi package (option 1)

Start the docker container and expose port 8000

```bash
docker compose up -d
```

### Option 2

#### Running the demo locally, using the longclaw package in editable mode (option 2)

The package should be available somewhere in your filesystem.

```bash
export LONGCLAW_PACKAGE_PATH=/path/to/longclaw
```

Start the docker container and expose port 8000

```bash
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d
```
$ docker run -it -p 8000:8000 longclaw-demo

```bash
docker compose exec web bash -c "pip install -e /longclaw"
```

### After starting the container

Run the migrations

```bash
docker compose exec web python manage.py migrate
```

Load the contries data

```bash
docker compose exec web python manage.py loadcountries
```

Create a superuser

```bash
docker compose exec web python manage.py createsuperuser
```

Load the initial data

```bash
make loaddata
```

Run the server

```bash
docker compose exec web python manage.py runserver 0.0.0.0:8000
```

Navigate to localhost:8000/admin and sign in with `admin`, `admin`
Navigate to localhost:8000/admin and sign in with the superuser you created above.
46 changes: 23 additions & 23 deletions catalog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,37 @@
# Generated by Django 2.1.4 on 2018-12-29 21:30
# Generated by Django 4.2.15 on 2024-08-30 10:45

from django.db import migrations, models
import django.db.models.deletion
import django_extensions.db.fields
import modelcluster.fields
import wagtail.core.fields
import wagtail.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
('wagtailimages', '0001_squashed_0021'),
('wagtailcore', '0041_group_collection_permissions_verbose_name_plural'),
('wagtailimages', '0025_alter_image_file_alter_rendition_file'),
('wagtailcore', '0089_log_entry_data_json_null_to_object'),
]

operations = [
migrations.CreateModel(
name='Product',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('description', wagtail.core.fields.RichTextField()),
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('description', wagtail.fields.RichTextField()),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
migrations.CreateModel(
name='ProductImage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('caption', models.CharField(blank=True, max_length=255)),
('image', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailimages.Image')),
('product', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='catalog.Product')),
],
options={
'ordering': ['sort_order'],
'abstract': False,
},
),
migrations.CreateModel(
name='ProductIndex',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
],
options={
'abstract': False,
Expand All @@ -60,11 +46,25 @@ class Migration(migrations.Migration):
('ref', models.CharField(max_length=32)),
('stock', models.IntegerField(default=0)),
('slug', django_extensions.db.fields.AutoSlugField(blank=True, editable=False, populate_from=('product', 'ref'), separator='')),
('description', wagtail.core.fields.RichTextField()),
('product', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='variants', to='catalog.Product')),
('description', wagtail.fields.RichTextField()),
('product', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='variants', to='catalog.product')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='ProductImage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('caption', models.CharField(blank=True, max_length=255)),
('image', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailimages.image')),
('product', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='catalog.product')),
],
options={
'ordering': ['sort_order'],
'abstract': False,
},
),
]
23 changes: 0 additions & 23 deletions catalog/migrations/0002_auto_20190105_1655.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.1.4 on 2019-01-05 17:25
# Generated by Django 4.2.15 on 2024-09-01 11:41

import django.core.validators
from django.db import migrations, models
Expand All @@ -7,7 +7,7 @@
class Migration(migrations.Migration):

dependencies = [
('catalog', '0002_auto_20190105_1655'),
('catalog', '0001_initial'),
]

operations = [
Expand All @@ -21,4 +21,14 @@ class Migration(migrations.Migration):
name='discount_percent',
field=models.PositiveSmallIntegerField(default=20, validators=[django.core.validators.MaxValueValidator(75)]),
),
migrations.AddField(
model_name='productvariant',
name='gluten_free',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='productvariant',
name='vegetarian',
field=models.BooleanField(default=False),
),
]
27 changes: 0 additions & 27 deletions catalog/migrations/0004_auto_20190116_0609.py

This file was deleted.

27 changes: 0 additions & 27 deletions catalog/migrations/0005_auto_20190116_0610.py

This file was deleted.

Loading