# Path: vulyk/blueprints/gamification/core/foundations.py
# class Fund:
#     """
#     Outer representation of different foundations we should keep:
#     donatable or not they are.
#     """
#     __slots__ = [
#         'id',
#         'name',
#         'description',
#         'site',
#         'email',
#         'logo',
#         'donatable'
#     ]
# 
#     def __init__(self,
#                  fund_id: str,
#                  name: str,
#                  description: str,
#                  site: str,
#                  email: str,
#                  logo: IOBase,
#                  donatable: bool) -> None:
#         # let's put it manually to use as an alias
#         """
#         :type fund_id: str
#         :type name: str
#         :type description: str
#         :type site: str
#         :type email: str
#         :type logo: IOBase
#         :type donatable: bool
#         """
#         self.id = fund_id
#         self.name = name
#         self.description = description
#         self.site = site
#         self.email = email
#         # this one should be an image file or *FSProxy, not sure yet
#         self.logo = logo
#         self.donatable = donatable
# 
#     def to_dict(self) -> Dict[str, str]:
#         """
#         Could be used as a source for JSON or any other representation format
# 
#         :return: Dict-ized object view
#         :rtype: dict
#         """
#         return {
#             'id': self.id,
#             'name': self.name,
#             'description': self.description,
#             'site': self.site,
#             'email': self.email,
#             'donatable': self.donatable
#         }
# 
#     def __eq__(self, o: object) -> bool:
#         if isinstance(o, Fund):
#             return o.id == self.id and o.name == self.name
#         else:
#             return False
# 
#     def __ne__(self, o: object) -> bool:
#         return not self == o
# 
#     def __str__(self) -> str:
#         return 'Fund({id}, {name}, {descr}, {site}, {email}, {donat})'.format(
#             id=self.id,
#             name=self.name,
#             descr=self.description[:20],
#             site=self.site,
#             email=self.email,
#             donat=self.donatable)
# 
#     def __repr__(self) -> str:
#         return str(self)


from enum import Enum
from typing import Iterator, Optional
from flask_mongoengine import Document
from mongoengine import (
    StringField, EmailField, ImageField, BooleanField, Q
)
from ..core.foundations import Fund
            name=self.name,
            description=self.description,
            site=self.site,
            email=self.email,
            logo=self.logo.get(),
            donatable=self.donatable)

    @classmethod
    def from_fund(cls, fund: Fund):
        """
        Fund to DB-specific model converter.

        :param fund: Current Fund instance
        :type fund: Fund

        :return: New FundModel instance
        :rtype: FundModel
        """
        result = cls(
            id=fund.id,
            name=fund.name,
            description=fund.description,
            site=fund.site,
            email=fund.email,
            donatable=fund.donatable)
        result.logo.put(fund.logo)

        return result

    @classmethod

# Path: vulyk/blueprints/gamification/core/foundations.py
# class Fund:
#     """
#     Outer representation of different foundations we should keep:
#     donatable or not they are.
#     """
#     __slots__ = [
#         'id',
#         'name',
#         'description',
#         'site',
#         'email',
#         'logo',
#         'donatable'
#     ]
# 
#     def __init__(self,
#                  fund_id: str,
#                  name: str,
#                  description: str,
#                  site: str,
#                  email: str,
#                  logo: IOBase,
#                  donatable: bool) -> None:
#         # let's put it manually to use as an alias
#         """
#         :type fund_id: str
#         :type name: str
#         :type description: str
#         :type site: str
#         :type email: str
#         :type logo: IOBase
#         :type donatable: bool
#         """
#         self.id = fund_id
#         self.name = name
#         self.description = description
#         self.site = site
#         self.email = email
#         # this one should be an image file or *FSProxy, not sure yet
#         self.logo = logo
#         self.donatable = donatable
# 
#     def to_dict(self) -> Dict[str, str]:
#         """
#         Could be used as a source for JSON or any other representation format
# 
#         :return: Dict-ized object view
#         :rtype: dict
#         """
#         return {
#             'id': self.id,
#             'name': self.name,
#             'description': self.description,
#             'site': self.site,
#             'email': self.email,
#             'donatable': self.donatable
#         }
# 
#     def __eq__(self, o: object) -> bool:
#         if isinstance(o, Fund):
#             return o.id == self.id and o.name == self.name
#         else:
#             return False
# 
#     def __ne__(self, o: object) -> bool:
#         return not self == o
# 
#     def __str__(self) -> str:
#         return 'Fund({id}, {name}, {descr}, {site}, {email}, {donat})'.format(
#             id=self.id,
#             name=self.name,
#             descr=self.description[:20],
#             site=self.site,
#             email=self.email,
#             donat=self.donatable)
# 
#     def __repr__(self) -> str:
#         return str(self)


# Path: vulyk/blueprints/gamification/models/foundations.py
from enum import Enum
from typing import Iterator, Optional
from flask_mongoengine import Document
from mongoengine import (
    StringField, EmailField, ImageField, BooleanField, Q
)
from ..core.foundations import Fund

            name=self.name,
            description=self.description,
            site=self.site,
            email=self.email,
            logo=self.logo.get(),
            donatable=self.donatable)

    @classmethod
    def from_fund(cls, fund: Fund):
        """
        Fund to DB-specific model converter.

        :param fund: Current Fund instance
        :type fund: Fund

        :return: New FundModel instance
        :rtype: FundModel
        """
        result = cls(
            id=fund.id,
            name=fund.name,
            description=fund.description,
            site=fund.site,
            email=fund.email,
            donatable=fund.donatable)
        result.logo.put(fund.logo)

        return result

    @classmethod

    def find_by_id(cls, fund_id: str) -> Optional[Fund]: