Skip to content

Commit

Permalink
Merge branch 'main' into may_13_session
Browse files Browse the repository at this point in the history
  • Loading branch information
JerrySentry authored May 15, 2024
2 parents 58e11cc + 83a5577 commit 1472777
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions api/internal/owner/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class StripeScheduledPhaseSerializer(serializers.Serializer):
quantity = serializers.SerializerMethodField()

def get_plan(self, phase):
plan_id = phase["plans"][0]["plan"]
plan_id = phase["items"][0]["plan"]
stripe_plan_dict = settings.STRIPE_PLAN_IDS
plan_name = list(stripe_plan_dict.keys())[
list(stripe_plan_dict.values()).index(plan_id)
Expand All @@ -208,7 +208,7 @@ def get_plan(self, phase):
return marketing_plan_name

def get_quantity(self, phase):
return phase["plans"][0]["quantity"]
return phase["items"][0]["quantity"]


class ScheduleDetailSerializer(serializers.Serializer):
Expand Down
8 changes: 4 additions & 4 deletions api/internal/tests/views/test_account_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_retrieve_account_gets_account_fields_when_there_are_scheduled_details(
{},
{
"start_date": schedule_params["start_date"],
"plans": [
"items": [
{
"plan": schedule_params["stripe_plan_id"],
"quantity": schedule_params["quantity"],
Expand Down Expand Up @@ -295,15 +295,15 @@ def test_retrieve_account_returns_last_phase_when_more_than_one_scheduled_phases
phases = [
{
"start_date": 123689126536,
"plans": [{"plan": "test_plan_123", "quantity": 4}],
"items": [{"plan": "test_plan_123", "quantity": 4}],
},
{
"start_date": 123689126636,
"plans": [{"plan": "test_plan_456", "quantity": 5}],
"items": [{"plan": "test_plan_456", "quantity": 5}],
},
{
"start_date": schedule_params["start_date"],
"plans": [
"items": [
{
"plan": schedule_params["stripe_plan_id"],
"quantity": schedule_params["quantity"],
Expand Down
2 changes: 1 addition & 1 deletion billing/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def test_subscription_schedule_updated_logs_changes_to_schedule(
"subscription": subscription_id,
"phases": [
{},
{"plans": [{"plan": new_plan, "quantity": new_quantity}]},
{"items": [{"plan": new_plan, "quantity": new_quantity}]},
],
}
},
Expand Down
2 changes: 1 addition & 1 deletion billing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def subscription_schedule_updated(self, schedule):
if schedule["subscription"]:
subscription = stripe.Subscription.retrieve(schedule["subscription"])
scheduled_phase = schedule["phases"][1]
scheduled_plan = scheduled_phase["plans"][0]
scheduled_plan = scheduled_phase["items"][0]
plan_id = scheduled_plan["plan"]
stripe_plan_dict = settings.STRIPE_PLAN_IDS
plan_name = list(stripe_plan_dict.keys())[
Expand Down
16 changes: 9 additions & 7 deletions docker/Dockerfile-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ ENV FRP_VERSION=v0.51.3
RUN apt-get update
RUN apt-get install -y curl

RUN addgroup -S frp \
&& adduser -D -S -h /var/frp -s /sbin/nologin -G frp frp \
&& curl -fSL https://github.com/fatedier/frp/releases/download/${FRP_VERSION}/frp_${FRP_VERSION:1}_linux_amd64.tar.gz -o frp.tar.gz \
&& tar -zxv -f frp.tar.gz \
&& rm -rf frp.tar.gz \
&& mv frp_*_linux_amd64 /frp \
&& chown -R frp:frp /frp
SHELL ["/bin/bash", "-c"]

RUN addgroup --system frp \
&& adduser --debug --system --home /var/frp --shell /sbin/nologin --ingroup frp frp \
&& curl -fSL https://github.com/fatedier/frp/releases/download/${FRP_VERSION}/frp_${FRP_VERSION:1}_linux_amd64.tar.gz -o frp.tar.gz \
&& tar -zxv -f frp.tar.gz \
&& rm -rf frp.tar.gz \
&& mv frp_*_linux_amd64 /frp \
&& chown -R frp:frp /frp

COPY --chown=frp:frp docker/frpc-entrypoint.sh /frp/entrypoint.sh
RUN chmod 755 /frp/entrypoint.sh
Expand Down
10 changes: 5 additions & 5 deletions services/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def _modify_subscription_schedule(
current_subscription_end_date = subscription["current_period_end"]

subscription_item = subscription["items"]["data"][0]
current_plan = subscription_item["plan"]["name"]
current_plan = subscription_item["plan"]["id"]
current_quantity = subscription_item["quantity"]

stripe.SubscriptionSchedule.modify(
Expand All @@ -265,10 +265,10 @@ def _modify_subscription_schedule(
{
"start_date": current_subscription_start_date,
"end_date": current_subscription_end_date,
"plans": [
"items": [
{
"plan": settings.STRIPE_PLAN_IDS[current_plan],
"price": settings.STRIPE_PLAN_IDS[current_plan],
"plan": current_plan,
"price": current_plan,
"quantity": current_quantity,
}
],
Expand All @@ -277,7 +277,7 @@ def _modify_subscription_schedule(
{
"start_date": current_subscription_end_date,
"end_date": current_subscription_end_date + SCHEDULE_RELEASE_OFFSET,
"plans": [
"items": [
{
"plan": settings.STRIPE_PLAN_IDS[desired_plan["value"]],
"price": settings.STRIPE_PLAN_IDS[desired_plan["value"]],
Expand Down
14 changes: 5 additions & 9 deletions services/tests/test_billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __init__(self, subscription_params):
{
"quantity": subscription_params["quantity"],
"id": subscription_params["id"],
"plan": {"name": subscription_params["name"]},
"plan": {"id": subscription_params["name"]},
}
]
}
Expand Down Expand Up @@ -195,14 +195,10 @@ def _assert_schedule_modify(
{
"start_date": subscription_params["start_date"],
"end_date": subscription_params["end_date"],
"plans": [
"items": [
{
"plan": settings.STRIPE_PLAN_IDS[
subscription_params["name"]
],
"price": settings.STRIPE_PLAN_IDS[
subscription_params["name"]
],
"plan": subscription_params["name"],
"price": subscription_params["name"],
"quantity": subscription_params["quantity"],
}
],
Expand All @@ -212,7 +208,7 @@ def _assert_schedule_modify(
"start_date": subscription_params["end_date"],
"end_date": subscription_params["end_date"]
+ SCHEDULE_RELEASE_OFFSET,
"plans": [
"items": [
{
"plan": settings.STRIPE_PLAN_IDS[desired_plan["value"]],
"price": settings.STRIPE_PLAN_IDS[desired_plan["value"]],
Expand Down

0 comments on commit 1472777

Please sign in to comment.