This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/endpoints/api/repoemail_models_pre_oci.py
Charlton Austin d01b55f27d refactor(endpoints/api/repoemail): added in pre_oci model
### Description of Changes

this is so we can abstract away the data interface

[TESTING->locally with docker compose]

Issue: https://coreosdev.atlassian.net/browse/QUAY-626

## Reviewer Checklist

- [ ] It works!
- [ ] Comments provide sufficient explanations for the next contributor
- [ ] Tests cover changes and corner cases
- [ ] Follows Quay syntax patterns and format
2017-07-13 15:30:07 -04:00

26 lines
1 KiB
Python

from data import model
from endpoints.api.repoemail_models_interface import RepoEmailDataInterface, RepositoryAuthorizedEmail
def _return_none_or_data(func, namespace_name, repository_name, email):
data = func(namespace_name, repository_name, email)
if data is None:
return data
return RepositoryAuthorizedEmail(email, repository_name, namespace_name, data.confirmed, data.code)
class PreOCIModel(RepoEmailDataInterface):
"""
PreOCIModel implements the data model for the Repo Email using a database schema
before it was changed to support the OCI specification.
"""
def get_email_authorized_for_repo(self, namespace_name, repository_name, email):
return _return_none_or_data(model.repository.get_email_authorized_for_repo, namespace_name, repository_name, email)
def create_email_authorization_for_repo(self, namespace_name, repository_name, email):
return _return_none_or_data(model.repository.create_email_authorization_for_repo, namespace_name, repository_name,
email)
pre_oci_model = PreOCIModel()