Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Allow the use of a Platform getting the certificate from settings.py #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
21 changes: 19 additions & 2 deletions scarface/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from boto.exception import BotoServerError
import re
from django.db import models
from django.conf import settings
from scarface.platform_strategy import get_strategies
from scarface.utils import DefaultConnection, PushLogger
from scarface.exceptions import SNSNotCreatedException, PlatformNotSupported, \
Expand Down Expand Up @@ -350,10 +351,26 @@ def resource_name(self):

@property
def attributes(self):
credential = self.get_platform_credential()
principal = self.get_platform_principal()
return {
"PlatformCredential": self.credential,
"PlatformPrincipal": self.principal
"PlatformCredential": credential,
"PlatformPrincipal": principal
}

def get_platform_credential(self):
if self.credential is not None and self.credential != '':
return self.credential
if hasattr(settings, 'SCARFACE_APNS_PRIVATE_KEY'):
return settings.SCARFACE_APNS_PRIVATE_KEY
return None

def get_platform_principal(self):
if self.principal is not None and self.principal != '':
return self.principal
if hasattr(settings, 'SCARFACE_APNS_CERTIFICATE'):
return settings.SCARFACE_APNS_CERTIFICATE
return None

@DefaultConnection
def register(self, connection=None):
Expand Down