Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
chore: PR to upgrade django oscar to version 3.2
Browse files Browse the repository at this point in the history
feat: resloved reserved keywords conflict

feat: add data mmigration to make basket_lineattribute value json compatible

docs: updated readme for 2u/release contributions (#3927)

docs: add decision record for master branch split

feat: add atlas pull support (#4051)

Refs: FC-0012 OEP-58

feat: added refund functionality
  • Loading branch information
zubair-ce07 committed Jan 16, 2024
1 parent e3860eb commit 2493b06
Show file tree
Hide file tree
Showing 19 changed files with 259 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ⛔️ MAIN BRANCH WARNING! 2U EMPLOYEES must make branches against the 2u/main BRANCH

- [ ] I have checked the branch to which I would like to merge.

# ⛔️ DEPRECATION WARNING

**This repository is deprecated and in maintainence-only operation while we work on a replacement, please see [this announcement](https://discuss.openedx.org/t/deprecation-removal-ecommerce-service-depr-22/6839) for more information.**
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ FROM ubuntu:focal as app
ENV DEBIAN_FRONTEND noninteractive
# System requirements.
RUN apt update && \
apt-get install -qy \
apt-get install -qy \
curl \
gettext \
git \
language-pack-en \
build-essential \
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ compile_translations: requirements.tox
fake_translations: extract_translations dummy_translations compile_translations

pull_translations:
ifeq ($(OPENEDX_ATLAS_PULL),)
cd ecommerce && tx pull -a -f -t --mode reviewed
else
find ecommerce/conf/locale -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \;
atlas pull $(OPENEDX_ATLAS_ARGS) translations/ecommerce/ecommerce/conf/locale:ecommerce/conf/locale
python manage.py compilemessages
endif

push_translations:
cd ecommerce && tx push -s
Expand Down
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ The code in this repository is licensed under version 3 of the AGPL unless other
How To Contribute
-----------------

Anyone merging to this repository is expected to `release and monitor their changes <https://openedx.atlassian.net/wiki/spaces/RS/pages/1835106870/How+to+contribute+to+our+repositories>`__; if you are not able to do this DO NOT MERGE, please coordinate with someone who can to ensure that the changes are released.
Notice: Internal 2U contributions should be made against the ``2u/main`` branch. Open source contributions should continue to be made against the ``master`` branch.

Please also read `How To Contribute <https://github.com/openedx/.github/blob/master/CONTRIBUTING.md>`__.
Anyone merging to the ``2u/main`` branch of this repository is expected to `release and monitor their changes <https://2u-internal.atlassian.net/wiki/spaces/RS/pages/7963261/How+to+contribute+to+our+repositories>`__ (2U-private link); if you are not able to do this DO NOT MERGE, please coordinate with someone who can to ensure that the changes are released.

Please also read `How To Contribute <https://github.com/openedx/.github/blob/master/CONTRIBUTING.md>`__. Even though it was written with ``edx-platform`` in mind, these guidelines should be followed for Open edX code in general.

Reporting Security Issues
-------------------------
Expand Down
5 changes: 5 additions & 0 deletions db_keyword_overrides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ MYSQL:
- ShippingEvent.lines
- PaymentEvent.lines
- ProductAlert.key
- HistoricalOption.order
- Option.order
SNOWFLAKE:
- HistoricalOption.order
- Option.order

STITCH:
52 changes: 52 additions & 0 deletions docs/decisions/0008-master-branch-split.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
8. Master branch split from 2u/main
------------------------------------------------------------

Status
------

Accepted

Context
-------

Both 2U and the Open edX community use ecommerce's master branch for releases. Occasionally, changes
specific to 2U's business case are merged into code, which also influences the structure
of the code that the community runs, even if the changes are not relevant or beneficial
to the community at large.

Additionally, 2U has internal compliance checks that can slow the release cycle of
major changes to ecommerce (for example, the upgrade to Django 4.2). This puts the Open edX community at risk of releasing
with deprecated packages.

Decision
--------

A new protected branch will be created named "2u/main", which 2U will continue to use
as its own main branch, while leaving the "master" branch for use by the community.

Consequences
------------

This allows the community to move forward with contributions on "master" without risk of
breaking functionality for 2U or 2U committing changes to "master" that are irrelevant or
otherwise inappropriate for the community's use case.

Because protected branches in ecommerce require a user with Write access to the repository,
the "master" branch will now require someone from the community to review and manage
code contributions to that branch.

Rejected Alternatives
---------------------

Repo fork
~~~~~~~~~

Why not fork the repo entirely? 2U and the community use a shared set of tools for
working in development environments. While working from separate branches and repo
forks are functionally equivalent, working in separate branches allows for
minimal updates to shared tooling to support this change. One can simply checkout a
branch name, without needing the tooling to be updated to know about non-openedx
git remotes.

This is not a one way door, and if we decide later the a proper repo fork is a better
solution, then we are open to making adjustments.
1 change: 1 addition & 0 deletions ecommerce/conf/locale/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@ ignore_dirs:
- i18n
- assets
- node_modules
- tests
- static/bower_components
- static/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
from django.core.paginator import Paginator
from django.db import migrations


def make_lineattribute_value_json_compatible(apps, schema_editor):
"""
Makes line attribute value json compatible.
"""
LineAttribute = apps.get_model("basket", "LineAttribute")
attributes = LineAttribute.objects.order_by('id')
paginator = Paginator(attributes, 1000)

for page_number in paginator.page_range:
page = paginator.page(page_number)
updates = []

for obj in page.object_list:
obj.value = '"{}"'.format(obj.value)
updates.append(obj)

LineAttribute.objects.bulk_update(updates, ['value'])


class Migration(migrations.Migration):

dependencies = [
('basket', '0015_add_paymentintentid'),
]

operations = [
migrations.RunPython(make_lineattribute_value_json_compatible, migrations.RunPython.noop),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.20 on 2023-12-05 10:34

import django.core.serializers.json
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('basket', '0016_make_lineattribute_value_json_compatible'),
]

operations = [
migrations.AlterField(
model_name='lineattribute',
name='value',
field=models.JSONField(encoder=django.core.serializers.json.DjangoJSONEncoder, verbose_name='Value'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Generated by Django 3.2.20 on 2023-12-05 10:34

from django.db import migrations, models
import django.db.models.deletion
import oscar.models.fields.slugfield


class Migration(migrations.Migration):

dependencies = [
('catalogue', '0056_auto_20231108_1355'),
]

operations = [
migrations.AlterModelOptions(
name='option',
options={'ordering': ['order', 'name'], 'verbose_name': 'Option', 'verbose_name_plural': 'Options'},
),
migrations.AddField(
model_name='historicaloption',
name='help_text',
field=models.CharField(blank=True, help_text='Help text shown to the user on the add to basket form', max_length=255, null=True, verbose_name='Help text'),
),
migrations.AddField(
model_name='historicaloption',
name='option_group',
field=models.ForeignKey(blank=True, db_constraint=False, help_text='Select an option group if using type "Option" or "Multi Option"', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='catalogue.attributeoptiongroup', verbose_name='Option Group'),
),
migrations.AddField(
model_name='historicaloption',
name='order',
field=models.IntegerField(blank=True, db_index=True, help_text='Controls the ordering of product options on product detail pages', null=True, verbose_name='Ordering'),
),
migrations.AddField(
model_name='option',
name='help_text',
field=models.CharField(blank=True, help_text='Help text shown to the user on the add to basket form', max_length=255, null=True, verbose_name='Help text'),
),
migrations.AddField(
model_name='option',
name='option_group',
field=models.ForeignKey(blank=True, help_text='Select an option group if using type "Option" or "Multi Option"', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='product_options', to='catalogue.attributeoptiongroup', verbose_name='Option Group'),
),
migrations.AddField(
model_name='option',
name='order',
field=models.IntegerField(blank=True, db_index=True, help_text='Controls the ordering of product options on product detail pages', null=True, verbose_name='Ordering'),
),
migrations.AlterField(
model_name='historicaloption',
name='type',
field=models.CharField(choices=[('text', 'Text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('date', 'Date'), ('select', 'Select'), ('radio', 'Radio'), ('multi_select', 'Multi select'), ('checkbox', 'Checkbox')], default='text', max_length=255, verbose_name='Type'),
),
migrations.AlterField(
model_name='historicalproduct',
name='slug',
field=oscar.models.fields.slugfield.SlugField(allow_unicode=True, max_length=255, verbose_name='Slug'),
),
migrations.AlterField(
model_name='option',
name='type',
field=models.CharField(choices=[('text', 'Text'), ('integer', 'Integer'), ('boolean', 'True / False'), ('float', 'Float'), ('date', 'Date'), ('select', 'Select'), ('radio', 'Radio'), ('multi_select', 'Multi select'), ('checkbox', 'Checkbox')], default='text', max_length=255, verbose_name='Type'),
),
migrations.AlterField(
model_name='product',
name='slug',
field=oscar.models.fields.slugfield.SlugField(allow_unicode=True, max_length=255, verbose_name='Slug'),
),
migrations.AlterUniqueTogether(
name='productattribute',
unique_together={('code', 'product_class')},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.20 on 2023-12-05 10:34

import django.core.serializers.json
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('order', '0026_auto_20231108_1355'),
]

operations = [
migrations.AlterField(
model_name='lineattribute',
name='value',
field=models.JSONField(encoder=django.core.serializers.json.DjangoJSONEncoder, verbose_name='Value'),
),
]
22 changes: 22 additions & 0 deletions ecommerce/templates/oscar/dashboard/orders/order_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ <h2>{% trans "Order Details" %}</h2>
{% trans "Order contents" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if active_tab == 'refunds' %}active{% endif %}" href="#refunds" data-toggle="tab">
{% trans "Refunds" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if active_tab == 'shipping' %}active{% endif %}" href="#shipping" data-toggle="tab">
{% trans "Shipping" %}
Expand Down Expand Up @@ -345,6 +350,15 @@ <h3>{% trans "With selected lines" %}:</h3>
<input id="amount_input" type="text" name="amount" value="" />
</div>
</div>
<div class="form-inline mb-sm-2">
<div class="form-group">
<div class="form-check">
<input id="create_refund" class="form-check-input" type="radio" name="line_action" value="create_refund" />
<label for="create_refund" class="form-check-label">{% trans "Create Refund" %}</label>
</div>
</div>
</div>

<div class="flex-nowrap">
<button type="submit" class="btn btn-primary">{% trans "Go!" %}</button>
</div>
Expand Down Expand Up @@ -540,6 +554,14 @@ <h3>{% trans "Shipping" %}</h3>
{% endblock %}
</div>

<div class="tab-pane fade {% if active_tab == 'refunds' %}show active{% endif %}" id="refunds" role="tabpanel">
{% block tab_refund %}
<div class="tab-pane {% if active_tab == 'refunds' %}active{% endif %}" id="refunds">
{% include "oscar/dashboard/partials/refund_table.html" with refunds=order.refunds.all %}
</div>
{% endblock %}
</div>

<div class="tab-pane fade {% if active_tab == 'payment' %}show active{% endif %}" id="payment" role="tabpanel">
{% block tab_payment %}

Expand Down
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ markdown==3.4.3
mysqlclient<1.5
newrelic
ndg-httpsclient
openedx-atlas
path.py==7.2
paypalrestsdk
premailer==2.9.2
Expand Down
4 changes: 3 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ django-libsass==0.9
# via -r requirements/base.in
django-model-utils==4.3.1
# via edx-rbac
django-oscar==3.1
django-oscar==3.2
# via
# -c requirements/constraints.txt
# -r requirements/base.in
Expand Down Expand Up @@ -362,6 +362,8 @@ oauthlib==3.2.2
# getsmarter-api-clients
# requests-oauthlib
# social-auth-core
openedx-atlas==0.5.0
# via -r requirements/base.in
packaging==23.1
# via drf-yasg
paramiko==3.2.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
cybersource-rest-client-python==0.0.21

# Django 3.2 support is added in version 2.2 so pinning it to 2.2
django-oscar==3.1
django-oscar==3.2

# Pinned because transifex-client==0.13.6 pins it
urllib3>=1.24.2,<2.0.0
Expand Down
6 changes: 4 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ django-model-utils==4.3.1
# via
# -r requirements/test.txt
# edx-rbac
django-oscar==3.1
django-oscar==3.2
# via -r requirements/test.txt
django-phonenumber-field==5.0.0
# via
Expand Down Expand Up @@ -333,7 +333,7 @@ edx-drf-extensions==9.0.0
# edx-rbac
edx-ecommerce-worker==3.3.4
# via -r requirements/test.txt
edx-i18n-tools==0.9.2
edx-i18n-tools==1.3.0
# via -r requirements/test.txt
edx-opaque-keys==2.3.0
# via
Expand Down Expand Up @@ -570,6 +570,8 @@ oauthlib==3.2.2
# getsmarter-api-clients
# requests-oauthlib
# social-auth-core
openedx-atlas==0.5.0
# via -r requirements/base.in
packaging==23.1
# via
# -r requirements/docs.txt
Expand Down
4 changes: 3 additions & 1 deletion requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ django-libsass==0.9
# via -r requirements/base.in
django-model-utils==4.3.1
# via edx-rbac
django-oscar==3.1
django-oscar==3.2
# via
# -c requirements/constraints.txt
# -r requirements/base.in
Expand Down Expand Up @@ -372,6 +372,8 @@ oauthlib==3.2.2
# getsmarter-api-clients
# requests-oauthlib
# social-auth-core
openedx-atlas==0.5.0
# via -r requirements/base.in
packaging==23.1
# via drf-yasg
paramiko==3.2.0
Expand Down
Loading

0 comments on commit 2493b06

Please sign in to comment.