Esempio n. 1
0
from assembl import models
from assembl.auth import CrudPermissions
from assembl.auth import Everyone, P_SYSADMIN, P_ADMIN_DISC
from assembl.auth.util import get_permissions
from assembl.lib.exceptions import LocalizableError
from assembl.views import JSONError
from .document import Document
from .types import SecureObjectType
from .utils import DateTime, abort_transaction_on_exception
from assembl.auth.password import random_string
from datetime import datetime
from .permissions_helpers import require_cls_permission, require_instance_permission
from .preferences import Preferences
from assembl.models.cookie_types import CookieTypes as PyCookieTypes

cookie_type_enum = PyEnum(
    'CookieTypes', [(k, k) for k in PyCookieTypes.values()])
CookieTypes = graphene.Enum.from_enum(cookie_type_enum)


class AgentProfile(SecureObjectType, SQLAlchemyObjectType):
    __doc__ = docs.AgentProfile.__doc__

    class Meta:
        model = models.AgentProfile
        interfaces = (Node, )
        only_fields = ('id',)

    user_id = graphene.Int(required=True, description=docs.AgentProfile.user_id)
    name = graphene.String(description=docs.AgentProfile.name)
    username = graphene.String(description=docs.AgentProfile.username)
    display_name = graphene.String(description=docs.AgentProfile.display_name)
Esempio n. 2
0
from assembl import models
import assembl.graphql.docstrings as docs
from assembl.auth import CrudPermissions
from assembl.graphql.langstring import LangStringEntryInput, langstring_from_input_entries, \
    update_langstring_from_input_entries
from assembl.graphql.permissions_helpers import require_cls_permission, require_instance_permission
from assembl.graphql import utils
from .document import Document
from .idea import IdeaUnion
from .langstring import (LangStringEntry, resolve_langstring,
                         resolve_langstring_entries)
from .types import SecureObjectType

synthesis_type_enum = PyEnum('SynthesisTypes', (
    (models.idea_graph_view.STRUCTURED_SYNTHESIS_TYPE,
     models.idea_graph_view.STRUCTURED_SYNTHESIS_TYPE),
    (models.idea_graph_view.FULLTEXT_SYNTHESIS_TYPE,
     models.idea_graph_view.FULLTEXT_SYNTHESIS_TYPE),
))
SynthesisTypes = graphene.Enum.from_enum(synthesis_type_enum)


class Synthesis(SecureObjectType, SQLAlchemyObjectType):
    __doc__ = docs.Synthesis.__doc__

    class Meta:
        model = models.Synthesis
        interfaces = (Node, )
        only_fields = ('id', )

    subject = graphene.String(lang=graphene.String(),
                              description=docs.Synthesis.subject)
Esempio n. 3
0
from .permissions_helpers import require_cls_permission
from .document import Document
from .idea import Idea
from .langstring import (LangStringEntry, resolve_best_langstring_entries,
                         resolve_langstring)
from .sentiment import SentimentCounts, SentimentTypes
from .types import SecureObjectType, SQLAlchemyInterface
from .user import AgentProfile
from .utils import DateTime, abort_transaction_on_exception
from .synthesis import Synthesis
from .extract import Extract, ExtractStates, ExtractNatures

_ = TranslationStringFactory('assembl')

publication_states_enum = PyEnum('PublicationStates',
                                 [(k, k)
                                  for k in models.PublicationStates.values()])
PublicationStates = graphene.Enum.from_enum(publication_states_enum)


class PostAttachment(SecureObjectType, SQLAlchemyObjectType):
    __doc__ = docs.PostAttachment.__doc__

    class Meta:
        model = models.PostAttachment
        only_fields = ('id', )

    document = graphene.Field(Document,
                              description=docs.PostAttachment.document)

Esempio n. 4
0
class LangStringEntryFields(graphene.AbstractType):
    value = graphene.String(required=True)
    locale_code = graphene.String(required=True)


class LangStringEntry(graphene.ObjectType, LangStringEntryFields):
    pass


class LangStringEntryInput(graphene.InputObjectType, LangStringEntryFields):
    pass


sentiments_enum = PyEnum('SentimentTypes',
                         (('LIKE', 'LIKE'), ('DISAGREE', 'DISAGREE'),
                          ('DONT_UNDERSTAND', 'DONT_UNDERSTAND'),
                          ('MORE_INFO', 'MORE_INFO')))
SentimentTypes = graphene.Enum.from_enum(sentiments_enum)


class AgentProfile(SecureObjectType, SQLAlchemyObjectType):
    class Meta:
        model = models.AgentProfile
        interfaces = (Node, )
        only_fields = ('id', 'name')


# class User(AgentProfile):
#     class Meta:
#         model = models.User
#         interfaces = (Node, )
Esempio n. 5
0
from graphene.relay import Node
from graphene_sqlalchemy import SQLAlchemyObjectType

import assembl.graphql.docstrings as docs
from assembl.auth import CrudPermissions
from assembl import models

from .permissions_helpers import require_instance_permission
from .types import SecureObjectType, SQLAlchemyInterface
from .utils import abort_transaction_on_exception, DateTime
from .user import AgentProfile

ExtractStates = graphene.Enum.from_enum(models.ExtractStates)

extract_natures_enum = PyEnum('ExtractNatures',
                              [(k.name, k.value)
                               for k in models.ExtractNatureVocabulary.Enum])

ExtractNatures = graphene.Enum.from_enum(extract_natures_enum)


class TextFragmentIdentifier(SecureObjectType, SQLAlchemyObjectType):
    __doc__ = docs.TextFragmentIdentifier.__doc__

    class Meta:
        model = models.TextFragmentIdentifier
        interfaces = (Node, )
        only_fields = ('xpath_start', 'xpath_end', 'offset_start',
                       'offset_end')