-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'customizable_from_address' into staging
- Loading branch information
Showing
12 changed files
with
1,494 additions
and
1,288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
from redturtle.prenotazioni.content.prenotazione import IPrenotazione | ||
from zope.component import adapter | ||
from zope.component import Interface | ||
from zope.interface import implementer | ||
|
||
import hashlib | ||
|
||
|
||
class IBookingCodeGenerator(Interface): | ||
""" | ||
Adapter interface to generate a code | ||
""" | ||
|
||
|
||
@implementer(IBookingCodeGenerator) | ||
@adapter(IPrenotazione, Interface) | ||
class BookingCodeGenerator: | ||
def __init__(self, context, request): | ||
self.context = context | ||
self.request = request | ||
|
||
def __call__(self, *args, **kwargs): | ||
hash_obj = hashlib.blake2b( | ||
bytes(self.context.UID(), encoding="utf8"), digest_size=3 | ||
) | ||
|
||
return hash_obj.hexdigest().upper() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,4 +191,7 @@ | |
/> | ||
|
||
|
||
<!-- code generator --> | ||
<adapter factory=".booking_code.BookingCodeGenerator" /> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.