eventplanner_gcal: PEP coding style

This commit is contained in:
Martin Bauer
2019-01-05 13:04:20 +01:00
parent aaf1528426
commit e2c8915321
10 changed files with 243 additions and 232 deletions

View File

@@ -32,28 +32,28 @@ class GCalPushChannel(models.Model):
resource_id = models.CharField(max_length=128)
expiration = models.IntegerField()
def toGChannel(self):
def to_google_channel(self):
return Channel('web_hook', self.id, self.token, self.address, self.expiration, resource_id=self.resource_id)
@staticmethod
def fromGChannel(gChannel):
return GCalPushChannel(id=gChannel.id,
address=gChannel.address,
token=gChannel.token,
expiration=gChannel.expiration,
resource_id=gChannel.resource_id)
def from_google_channel(google_channel):
return GCalPushChannel(id=google_channel.id,
address=google_channel.address,
token=google_channel.token,
expiration=google_channel.expiration,
resource_id=google_channel.resource_id)
@staticmethod
def createNew(callbackUrl, service, ttl=None):
gChannel = Channel('web_hook', str(uuid.uuid4()), 'blechreizGcal', callbackUrl, params={'ttl': int(ttl)})
def create_new(callback_url, service, ttl=None):
gChannel = Channel('web_hook', str(uuid.uuid4()), 'blechreizGcal', callback_url, params={'ttl': int(ttl)})
response = service.events().watch(calendarId='primary', body=gChannel.body()).execute()
gChannel.update(response)
dbChannel = GCalPushChannel.fromGChannel(gChannel)
dbChannel = GCalPushChannel.from_google_channel(gChannel)
dbChannel.save()
@staticmethod
def stop(service, gChannel):
channelService = service.channels()
channelService.stop(body=gChannel.body()).execute()
GCalPushChannel.fromGChannel(gChannel).delete()
def stop(service, google_channel):
channel_service = service.channels()
channel_service.stop(body=google_channel.body()).execute()
GCalPushChannel.from_google_channel(google_channel).delete()