Skip to content

Commit eed013f

Browse files
Merge branch 'main' into dependabot/npm_and_yarn/frontend/eslint-plugin-cypress-2.15.1
2 parents acdd98c + 6e943f9 commit eed013f

File tree

43 files changed

+928
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+928
-113
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: actions/checkout@v4
3232

3333
- name: Set up Python
34-
uses: actions/setup-python@v4
34+
uses: actions/setup-python@v5
3535
with:
3636
python-version: "3.9.7"
3737

@@ -340,7 +340,7 @@ jobs:
340340
wait-for-service-stability: true
341341

342342
- name: Sentry release
343-
uses: getsentry/action-release@v1.4.1
343+
uses: getsentry/action-release@v1.7.0
344344
env:
345345
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
346346
SENTRY_ORG: ${{ env.SENTRY_ORG }}

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v2
46+
uses: github/codeql-action/init@v3
4747
with:
4848
languages: ${{ matrix.language }}
4949
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
5454
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5555
# If this step fails, then you should remove it and run the build manually (see below)
5656
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v2
57+
uses: github/codeql-action/autobuild@v3
5858

5959
# ℹ️ Command-line programs to run using the OS shell.
6060
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
6868
# make release
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v2
71+
uses: github/codeql-action/analyze@v3

backend/.env.development

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ AWS_SES_REGION_ENDPOINT=email.eu-north-1.amazonaws.com
1010
AWS_SES_REGION_NAME=eu-north-1
1111
CONTACT_EMAIL=[email protected]
1212
CORS_ALLOW_CREDENTIALS=true
13-
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://frontend:3000
13+
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://frontend:3000,http://127.0.0.1:3000
1414
CSRF_COOKIE_DOMAIN=localhost
1515
CSRF_COOKIE_NAME=csrf
1616
CSRF_FAILURE_VIEW=config.views.csrf.csrf_failure
17-
CSRF_TRUSTED_ORIGINS=http://localhost:3000,http://frontend:3000
17+
CSRF_TRUSTED_ORIGINS=http://localhost:3000,http://frontend:3000,http://127.0.0.1:3000
1818
DATAPORTEN_ID=fcaa9e30-a6d3-4809-8fea-cdd7b3de1c98
1919
DATAPORTEN_REDIRECT_URI=http://localhost:3000/authCallback
2020
DATAPORTEN_SECRET=<INSERT DATAPORTEN SECRET>
21-
DJANGO_ALLOWED_HOSTS=0.0.0.0,localhost,backend,127.0.0.1
21+
DJANGO_ALLOWED_HOSTS=0.0.0.0,localhost,backend,127.0.0.1,http://127.0.0.1:3000
2222
DJANGO_DEFAULT_FROM_EMAIL=Indøk <[email protected]>
2323
DJANGO_EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
2424
DJANGO_ENVIRONMENT=development
2525
DJANGO_SETTINGS_MODULE=config.settings.local
2626
EMAIL_MAX_RECIPIENTS=50
27-
FRONTEND_BASE_URL=http://localhost:3000
27+
FRONTEND_BASE_URL=http://localhost:3000,http://127.0.0.1:3000
2828
GOOGLE_DRIVE_API_KEY=<INSERT GOOGLE API KEY>
2929
POSTMARK_SERVER_TOKEN=<INSERT POSTMARK SERVER TOKEN>
3030
ROOT_URLCONF=config.urls.local
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 3.2.22 on 2024-02-26 17:15
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("cabins", "0028_auto_20231113_2045"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="booking",
15+
name="phone",
16+
field=models.CharField(max_length=15),
17+
),
18+
migrations.AlterField(
19+
model_name="bookingresponsible",
20+
name="phone",
21+
field=models.CharField(max_length=15),
22+
),
23+
]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 3.2.22 on 2024-02-15 17:51
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("ecommerce", "0002_auto_20220120_1911"),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name="product",
14+
name="shop_item",
15+
field=models.BooleanField(default=False),
16+
),
17+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.2.22 on 2024-02-26 17:15
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("ecommerce", "0003_product_shop_item"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="order",
15+
name="delivered",
16+
field=models.BooleanField(default=False),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.2.22 on 2024-02-29 18:06
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("ecommerce", "0004_order_delivered"),
10+
]
11+
12+
operations = [
13+
migrations.RenameField(
14+
model_name="order",
15+
old_name="delivered",
16+
new_name="delivered_product",
17+
),
18+
]

backend/apps/ecommerce/models.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@
66
from django.db import models, transaction
77
from django.db.models import F, Sum
88
from django.db.models.fields import DateTimeField, UUIDField
9+
from apps.ecommerce.mixins import Sellable
10+
from django.contrib.contenttypes.fields import GenericRelation
11+
12+
# from django.contrib.postgres.fields import ArrayField
913

1014
from apps.organizations.models import Organization
1115
from apps.users.models import User
1216

1317

14-
class Product(models.Model):
18+
class Product(models.Model, Sellable):
1519
name = models.CharField(max_length=200)
1620
price = models.DecimalField(max_digits=11, decimal_places=2)
1721
description = models.TextField()
1822
organization = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="products")
1923
total_quantity = models.PositiveIntegerField()
2024
current_quantity = models.PositiveIntegerField(null=True) # Set to total_quantity upon initialization
2125
max_buyable_quantity = models.PositiveIntegerField(default=1)
26+
shop_item = models.BooleanField(default=False)
27+
products = GenericRelation("ecommerce.Product")
2228

2329
# Generic foreign key to related product model instance (e.g event model)
2430
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, null=True, blank=True)
@@ -110,6 +116,7 @@ class PaymentStatus(models.TextChoices):
110116
timestamp = DateTimeField(auto_now_add=True)
111117
auth_token = models.CharField(max_length=32, default=get_auth_token) # For authenticating Vipps callback
112118
payment_attempt = models.PositiveIntegerField(default=1)
119+
delivered_product = models.BooleanField(default=False)
113120

114121
def __str__(self):
115122
return f"Order(product={self.product}, user={self.user})"

backend/apps/ecommerce/mutations.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,26 @@ def mutate(self, info, product_data):
170170
ok = True
171171

172172
return CreateProduct(product=product, ok=ok)
173+
174+
175+
class DeliveredProduct(graphene.Mutation):
176+
ok = graphene.Boolean()
177+
order = graphene.Field(OrderType)
178+
179+
class Arguments:
180+
order_id = graphene.ID(required=True)
181+
182+
@staff_member_required
183+
def mutate(self, info, order_id):
184+
try:
185+
order = Order.objects.get(id=order_id)
186+
if order.delivered_product is False:
187+
order.delivered_product = True
188+
elif order.delivered_product is True:
189+
order.delivered_product = False
190+
order.save()
191+
ok = True
192+
except Order.DoesNotExist:
193+
raise ValueError("Cannot identify order.")
194+
195+
return DeliveredProduct(order=order, ok=ok)

backend/apps/ecommerce/resolvers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def resolve_product(self, info: "ResolveInfo", product_id: int):
1414
except Product.DoesNotExist:
1515
return None
1616

17-
@staff_member_required
17+
@login_required
1818
def resolve_products(self, info):
1919
return Product.objects.all()
2020

@@ -34,6 +34,10 @@ def get_products(self, info):
3434
def resolve_user_orders(self, info):
3535
return Order.objects.filter(user=info.context.user)
3636

37+
@staff_member_required
38+
def resolve_all_user_orders(self, info):
39+
return Order.objects.all()
40+
3741
@staff_member_required
3842
def resolve_orders_by_status(self, info: "ResolveInfo", product_id, status):
3943
orders = Order.objects.filter(product_id=product_id, payment_status=status)

0 commit comments

Comments
 (0)