Skip to content

Commit

Permalink
Merge pull request #157 from purplship/purplship-2021.11
Browse files Browse the repository at this point in the history
[release-candidate] purplship 2021.11
  • Loading branch information
danh91 authored Dec 8, 2021
2 parents 46e717a + 63de560 commit 8787ccc
Show file tree
Hide file tree
Showing 360 changed files with 95,780 additions and 35,727 deletions.
17 changes: 10 additions & 7 deletions .codegen/typescript/api/purplship.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { PurplshipClient } from './index';
import { ConfigurationParameters, PurplshipClient } from './index';

export const Client = PurplshipClient;
export default function Purplship(apiKey: string, host: string = 'https://cloud.purplship.com', apiKeyPrefix: string = 'Token') {
const clientConfig: ConfigurationParameters = {
basePath: host,
apiKey: `${apiKeyPrefix} ${apiKey}`,
};

export class Purplship extends PurplshipClient {
constructor({ apiKey, host }: { apiKey: string, host: string }) {
super({ basePath: host, apiKey });
}
}
return new PurplshipClient(clientConfig);
}

Purplship.Client = PurplshipClient;
2 changes: 1 addition & 1 deletion .codegen/typescript/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ gulp.task('build', async function () {
await bundle.write({
file: output,
format: 'umd',
name: 'purplship',
name: 'Purplship',
sourcemap: true
});
});
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ venv.bak/
.DS_Store

# purplship stuff:
sdk/**/poetry.lock
schemas/**/poetry.lock
.bash_history
*.DS_Store
.idea/
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ docker run -d \
-e ADMIN_EMAIL=admin@example.com \
-e ADMIN_PASSWORD=demo \
--link=db:db -p 5002:5002 \
danh91.docker.scarf.sh/purplship/server:2021.10
danh91.docker.scarf.sh/purplship/server:2021.11
```

</details>
Expand All @@ -92,7 +92,7 @@ services:
- db_network

pship:
image: danh91.docker.scarf.sh/purplship/server:2021.10
image: danh91.docker.scarf.sh/purplship/server:2021.11
restart: unless-stopped
environment:
- DEBUG_MODE=True
Expand Down Expand Up @@ -163,6 +163,7 @@ pip install purplship.canadapost
- `purplship.canadapost`
- `purplship.canpar`
- `purplship.dhl-express`
- `purplship.dhl-poland`
- `purplship.dhl-universal`
- `purplship.dicom`
- `purplship.fedex`
Expand All @@ -189,7 +190,7 @@ pip install purplship.canadapost
```python
import purplship
from purplship.core.models import Address, Parcel, RateRequest
from purplship.mappers.canadapost.settings import Settings
from purplship.mappers.canadapost import Settings


# Initialize a carrier gateway
Expand Down
11 changes: 2 additions & 9 deletions docker-compose.insiders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,9 @@ services:
file: docker-compose.yml
service: redis

nginx:
extends:
file: docker-compose.yml
service: nginx


volumes:
redisdata:
pshipdata:
redisdata: null
pshipdata: null
pshipstatics:
driver: local

Expand All @@ -61,4 +55,3 @@ networks:
driver: bridge
web_network:
driver: bridge

9 changes: 7 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# The base image compilation
FROM python:3.8-slim AS compile-image

ARG REQUIREMENTS="requirements.txt"
ARG REGISTRY_TOKEN
ARG REGISTRY_TOKEN_NAME

RUN python -m venv /pship/venv
ENV PATH="/pship/venv/bin:$PATH"
COPY requirements.txt /temp/
COPY "${REQUIREMENTS}" /temp/
RUN pip install --upgrade pip && \
pip install dumb-init && \
pip install -r /temp/requirements.txt
pip install -r "/temp/${REQUIREMENTS}"


# The runtime image
Expand Down
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Setup DB and static files
purplship migrate || exit
purplship collectstatic --clear --noinput || exit
purplship collectstatic --clear --noinput 2>&1 || exit

# Setup Default super admin
(echo "
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.9 on 2021-11-13 13:38

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('events', '0002_event'),
('orgs', '0003_organization_system_carriers'),
]

operations = [
migrations.CreateModel(
name='EventLink',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('item', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='link', to='events.event')),
('org', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='event_links', to='orgs.organization')),
],
),
migrations.AddField(
model_name='organization',
name='events',
field=models.ManyToManyField(related_name='org', through='orgs.EventLink', to='events.Event'),
),
]
179 changes: 132 additions & 47 deletions insiders/server/orgs/purplship/server/orgs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
AbstractOrganization,
AbstractOrganizationUser,
AbstractOrganizationOwner,
AbstractOrganizationInvitation
AbstractOrganizationInvitation,
)

import purplship.server.providers.models as providers
Expand All @@ -17,38 +17,66 @@


class Organization(AbstractOrganization):
id = models.CharField(max_length=50, primary_key=True, default=partial(core.uuid, prefix='org_'), editable=False)

carriers = models.ManyToManyField(providers.Carrier, related_name="org", through='CarrierLink')
system_carriers = models.ManyToManyField(providers.Carrier, related_name="active_orgs")

parcels = models.ManyToManyField(manager.Parcel, related_name="org", through='ParcelLink')
pickups = models.ManyToManyField(manager.Pickup, related_name="org", through='PickupLink')
customs = models.ManyToManyField(manager.Customs, related_name="org", through='CustomsLink')
trackers = models.ManyToManyField(manager.Tracking, related_name="org", through='TrackerLink')
addresses = models.ManyToManyField(manager.Address, related_name="org", through='AddressLink')
shipments = models.ManyToManyField(manager.Shipment, related_name="org", through='ShipmentLink')
commodities = models.ManyToManyField(manager.Commodity, related_name="org", through='CommodityLink')

templates = models.ManyToManyField(graph.Template, related_name="org", through='TemplateLink')

webhooks = models.ManyToManyField(events.Webhook, related_name="org", through='WebhookLink')

logs = models.ManyToManyField(core.APILog, related_name="org", through='LogLink')

tokens = models.ManyToManyField(auth.Token, related_name="org", through='TokenLink')
id = models.CharField(
max_length=50,
primary_key=True,
default=partial(core.uuid, prefix="org_"),
editable=False,
)

carriers = models.ManyToManyField(
providers.Carrier, related_name="org", through="CarrierLink"
)
system_carriers = models.ManyToManyField(
providers.Carrier, related_name="active_orgs"
)

parcels = models.ManyToManyField(
manager.Parcel, related_name="org", through="ParcelLink"
)
pickups = models.ManyToManyField(
manager.Pickup, related_name="org", through="PickupLink"
)
customs = models.ManyToManyField(
manager.Customs, related_name="org", through="CustomsLink"
)
trackers = models.ManyToManyField(
manager.Tracking, related_name="org", through="TrackerLink"
)
addresses = models.ManyToManyField(
manager.Address, related_name="org", through="AddressLink"
)
shipments = models.ManyToManyField(
manager.Shipment, related_name="org", through="ShipmentLink"
)
commodities = models.ManyToManyField(
manager.Commodity, related_name="org", through="CommodityLink"
)

templates = models.ManyToManyField(
graph.Template, related_name="org", through="TemplateLink"
)

webhooks = models.ManyToManyField(
events.Webhook, related_name="org", through="WebhookLink"
)
events = models.ManyToManyField(
events.Event, related_name="org", through="EventLink"
)

logs = models.ManyToManyField(core.APILog, related_name="org", through="LogLink")

tokens = models.ManyToManyField(auth.Token, related_name="org", through="TokenLink")

surcharges = models.ManyToManyField(pricing.Surcharge, related_name="org")


class OrganizationUser(AbstractOrganizationUser):

def __str__(self):
return f"{self.user.email} ({self.organization.name})"


class OrganizationOwner(AbstractOrganizationOwner):

def __str__(self):
return "{0}: {1}".format(self.organization, self.organization_user.user.email)

Expand All @@ -61,60 +89,117 @@ class OrganizationInvitation(AbstractOrganizationInvitation):


class CarrierLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="carrier_links")
item = models.OneToOneField(providers.Carrier, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="carrier_links"
)
item = models.OneToOneField(
providers.Carrier, on_delete=models.CASCADE, related_name="link"
)


class ParcelLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="parcel_links")
item = models.OneToOneField(manager.Parcel, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="parcel_links"
)
item = models.OneToOneField(
manager.Parcel, on_delete=models.CASCADE, related_name="link"
)


class PickupLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="pickup_links")
item = models.OneToOneField(manager.Pickup, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="pickup_links"
)
item = models.OneToOneField(
manager.Pickup, on_delete=models.CASCADE, related_name="link"
)


class CustomsLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="custom_links")
item = models.OneToOneField(manager.Customs, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="custom_links"
)
item = models.OneToOneField(
manager.Customs, on_delete=models.CASCADE, related_name="link"
)


class TrackerLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="tracker_links")
item = models.OneToOneField(manager.Tracking, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="tracker_links"
)
item = models.OneToOneField(
manager.Tracking, on_delete=models.CASCADE, related_name="link"
)


class AddressLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="address_links")
item = models.OneToOneField(manager.Address, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="address_links"
)
item = models.OneToOneField(
manager.Address, on_delete=models.CASCADE, related_name="link"
)


class ShipmentLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="shipment_links")
item = models.OneToOneField(manager.Shipment, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="shipment_links"
)
item = models.OneToOneField(
manager.Shipment, on_delete=models.CASCADE, related_name="link"
)


class CommodityLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="commodity_links")
item = models.OneToOneField(manager.Commodity, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="commodity_links"
)
item = models.OneToOneField(
manager.Commodity, on_delete=models.CASCADE, related_name="link"
)


class TemplateLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="template_links")
item = models.OneToOneField(graph.Template, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="template_links"
)
item = models.OneToOneField(
graph.Template, on_delete=models.CASCADE, related_name="link"
)


class WebhookLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="webhook_links")
item = models.OneToOneField(events.Webhook, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="webhook_links"
)
item = models.OneToOneField(
events.Webhook, on_delete=models.CASCADE, related_name="link"
)


class EventLink(models.Model):
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="event_links"
)
item = models.OneToOneField(
events.Event, on_delete=models.CASCADE, related_name="link"
)


class LogLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="log_links")
item = models.OneToOneField(core.APILog, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="log_links"
)
item = models.OneToOneField(
core.APILog, on_delete=models.CASCADE, related_name="link"
)


class TokenLink(models.Model):
org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name="token_links")
item = models.OneToOneField(auth.Token, on_delete=models.CASCADE, related_name="link")
org = models.ForeignKey(
Organization, on_delete=models.CASCADE, related_name="token_links"
)
item = models.OneToOneField(
auth.Token, on_delete=models.CASCADE, related_name="link"
)
Loading

0 comments on commit 8787ccc

Please sign in to comment.