Esempio n. 1
0
def init_app(app):
    if superdesk.app.config.get('SUPERDESK_TESTING', False):
        endpoint_name = 'prepopulate'
        service = PrepopulateService(endpoint_name, backend=superdesk.get_backend())
        PrepopulateResource(endpoint_name, app=app, service=service)

        superdesk.intrinsic_privilege(resource_name=endpoint_name, method=['POST'])
Esempio n. 2
0
def init_app(app):
    for instance_name in instances:
        name = 'scanpix({})'.format(instance_name)
        scanpix = ScanpixDatalayer(app)
        service = SearchIngestService(datasource=None, backend=scanpix, source=name)
        SearchIngestResource(endpoint_name=name, app=app, service=service)
        intrinsic_privilege(resource_name=name, method=['GET', 'POST'])
Esempio n. 3
0
def init_app(app):
    endpoint_name = 'preferences'
    service = PreferencesService(endpoint_name, backend=get_backend())
    PreferencesResource(endpoint_name, app=app, service=service)

    superdesk.intrinsic_privilege(resource_name=endpoint_name,
                                  method=['PATCH'])
Esempio n. 4
0
def init_app(app):
    endpoint_name = 'fetch'
    service = FetchService(endpoint_name, backend=superdesk.get_backend())
    FetchResource(endpoint_name, app=app, service=service)

    endpoint_name = 'duplicate'
    service = DuplicateService(endpoint_name, backend=superdesk.get_backend())
    DuplicateResource(endpoint_name, app=app, service=service)

    endpoint_name = 'translate'
    service = TranslateService(endpoint_name, backend=superdesk.get_backend())
    TranslateResource(endpoint_name, app=app, service=service)

    endpoint_name = 'copy'
    service = CopyService(endpoint_name, backend=superdesk.get_backend())
    CopyResource(endpoint_name, app=app, service=service)

    endpoint_name = 'move'
    service = MoveService(endpoint_name, backend=superdesk.get_backend())
    MoveResource(endpoint_name, app=app, service=service)

    superdesk.privilege(name='fetch', label='Fetch Content To a Desk', description='Fetch Content to a Desk')
    superdesk.privilege(name='move', label='Move Content to another desk', description='Move Content to another desk')
    superdesk.privilege(name='duplicate', label='Duplicate Content within a Desk',
                        description='Duplicate Content within a Desk')
    superdesk.privilege(name='translate', label='Translate Content within a Desk',
                        description='Translate Content within a Desk')

    superdesk.intrinsic_privilege('copy', method=['POST'])
Esempio n. 5
0
def init_app(app):
    aapmm_datalayer = AAPMMDatalayer(app)
    service = SearchIngestService(datasource=None,
                                  backend=aapmm_datalayer,
                                  source=PROVIDER_NAME)
    SearchIngestResource(endpoint_name=PROVIDER_NAME, service=service, app=app)
    intrinsic_privilege(resource_name=PROVIDER_NAME, method=['GET', 'POST'])
Esempio n. 6
0
def init_app(app):

    endpoint_name = 'ingest'
    service = AppIngestService(endpoint_name, backend=superdesk.get_backend())
    IngestResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_versions'
    service = ArchiveVersionsService(endpoint_name, backend=superdesk.get_backend())
    ArchiveVersionsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive'
    service = ArchiveService(endpoint_name, backend=superdesk.get_backend())
    ArchiveResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_lock'
    service = ArchiveLockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveLockResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_unlock'
    service = ArchiveUnlockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnlockResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_spike'
    service = ArchiveSpikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveSpikeResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_unspike'
    service = ArchiveUnspikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnspikeResource(endpoint_name, app=app, service=service)

    endpoint_name = 'user_content'
    service = UserContentService(endpoint_name, backend=superdesk.get_backend())
    UserContentResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_rewrite'
    service = ArchiveRewriteService(endpoint_name, backend=superdesk.get_backend())
    ArchiveRewriteResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_autosave'
    service = ArchiveSaveService(endpoint_name, backend=superdesk.get_backend())
    AutoSaveResource(endpoint_name, app=app, service=service)

    from apps.item_autosave.components.item_autosave import ItemAutosave
    from apps.item_autosave.models.item_autosave import ItemAutosaveModel
    register_component(ItemLock(app))
    register_model(ItemModel(EveProxy(superdesk.get_backend())))
    register_component(ItemAutosave(app))
    register_model(ItemAutosaveModel(EveProxy(superdesk.get_backend())))

    superdesk.privilege(name='archive', label='Archive', description='User can view the published content.')
    superdesk.privilege(name='ingest', label='Ingest', description='User can view content in ingest and fetch it.')
    superdesk.privilege(name='spike', label='Spike', description='User can spike content.')
    superdesk.privilege(name='unspike', label='Un Spike', description='User can un-spike content.')
    superdesk.privilege(name='unlock', label='Unlock content', description='User can unlock content.')
    superdesk.privilege(name='metadata_uniquename', label='Edit Unique Name', description='User can edit unique name.')
    superdesk.privilege(name='hold', label='Hold', description='Hold a content')
    superdesk.privilege(name='restore', label='Restore', description='Restore a hold a content')
    superdesk.privilege(name='rewrite', label='Update', description='Update a published content')

    superdesk.intrinsic_privilege(ArchiveUnlockResource.endpoint_name, method=['POST'])
Esempio n. 7
0
def init_app(app):
    endpoint_name = 'preferences'
    service = PreferencesService(endpoint_name, backend=get_backend())
    PreferencesResource(endpoint_name, app=app, service=service)
    app.on_session_end -= service.on_session_end
    app.on_session_end += service.on_session_end

    superdesk.intrinsic_privilege(resource_name=endpoint_name, method=['PATCH'])
Esempio n. 8
0
def init_app(app):

    endpoint_name = 'activity'
    service = ActivityService(endpoint_name, backend=superdesk.get_backend())
    ActivityResource(endpoint_name, app=app, service=service)

    # Registering with intrinsic privileges because: A user should be able to mark as read their own notifications.
    superdesk.intrinsic_privilege(resource_name='activity', method=['PATCH'])
Esempio n. 9
0
def init_app(app):

    endpoint_name = 'activity'
    service = ActivityService(endpoint_name, backend=superdesk.get_backend())
    ActivityResource(endpoint_name, app=app, service=service)

    # Registering with intrinsic privileges because: A user should be able to mark as read their own notifications.
    superdesk.intrinsic_privilege(resource_name='activity', method=['PATCH'])
Esempio n. 10
0
def init_app(app):
    endpoint_name = 'preferences'
    service = PreferencesService(endpoint_name, backend=get_backend())
    PreferencesResource(endpoint_name, app=app, service=service)
    app.on_session_end -= service.on_session_end
    app.on_session_end += service.on_session_end
    app.on_role_privileges_updated -= service.on_role_privileges_updated
    app.on_role_privileges_updated += service.on_role_privileges_updated
    superdesk.intrinsic_privilege(resource_name=endpoint_name, method=['PATCH'])
Esempio n. 11
0
def init_app(app):
    endpoint_name = 'users'
    service = DBUsersService(endpoint_name, backend=superdesk.get_backend())
    UsersResource(endpoint_name, app=app, service=service)

    superdesk.privilege(name='users', label='User Management', description='User can manage users.')

    # Registering with intrinsic privileges because: A user should be allowed to update their own profile.
    superdesk.intrinsic_privilege(resource_name='users', method=['PATCH'])
Esempio n. 12
0
def init_app(app):
    endpoint_name = 'upload'
    service = UploadService(endpoint_name, backend=superdesk.get_backend())
    UploadResource(endpoint_name, app=app, service=service)
    superdesk.blueprint(bp, app)
    app.upload_url = upload_url

    # Using intrinsic privilege so that any user can update their profile Avatar
    # This still restricts this endpoint to logged in users only
    superdesk.intrinsic_privilege(resource_name='upload', method=['POST'])
Esempio n. 13
0
def init_app(app):
    endpoint_name = 'users'
    service = DBUsersService(endpoint_name, backend=superdesk.get_backend())
    UsersResource(endpoint_name, app=app, service=service)

    superdesk.privilege(name='users',
                        label='User Management',
                        description='User can manage users.')

    # Registering with intrinsic privileges because: A user should be allowed to update their own profile.
    superdesk.intrinsic_privilege(resource_name='users', method=['PATCH'])
Esempio n. 14
0
def init_app(app):
    # Must be imported here as the constant PROVIDER_NAME is referenced by the below modules
    from .aap_mm_datalayer import AAPMMDatalayer
    from .resource import AAPMMResource
    from .service import AAPMMService

    app.data.aapmm = AAPMMDatalayer(app)

    aapmm_service = AAPMMService(datasource=None, backend=app.data.aapmm)
    AAPMMResource(endpoint_name=PROVIDER_NAME, app=app, service=aapmm_service)

    intrinsic_privilege(resource_name=PROVIDER_NAME, method=['GET', 'POST'])
Esempio n. 15
0
def init_app(app):
    endpoint_name = 'spellcheckers_list'
    service = SpellcheckersListService(endpoint_name, backend=superdesk.get_backend())
    SpellcheckersListResource(endpoint_name, app=app, service=service)

    endpoint_name = 'spellchecker'
    service = SpellcheckerService(endpoint_name, backend=superdesk.get_backend())
    SpellcheckerResource(endpoint_name, app=app, service=service)
    superdesk.intrinsic_privilege(endpoint_name, method=['POST'])

    if AUTO_IMPORT:
        importSpellcheckers(app, __name__)
Esempio n. 16
0
def init_app(app):
    endpoint_name = "spellcheckers_list"
    service = SpellcheckersListService(endpoint_name, backend=superdesk.get_backend())
    SpellcheckersListResource(endpoint_name, app=app, service=service)

    endpoint_name = "spellchecker"
    service = SpellcheckerService(endpoint_name, backend=superdesk.get_backend())
    SpellcheckerResource(endpoint_name, app=app, service=service)
    superdesk.intrinsic_privilege(endpoint_name, method=["POST"])

    if AUTO_IMPORT:
        tools.import_services(app, __name__, SpellcheckerBase)
Esempio n. 17
0
def init_app(app) -> None:
    endpoint_name = "concept_items"
    service = ConceptItemsService(endpoint_name, backend=superdesk.get_backend())
    ConceptItemsResource(endpoint_name, app=app, service=service)

    superdesk.privilege(
        name=CONCEPT_ITEMS_PRIVELEGE,
        label=lazy_gettext("Knowledge base management"),
        description=lazy_gettext("User can manage annotations library."),
    )

    # let everyone create concepts (SDESK-4959)
    superdesk.intrinsic_privilege(endpoint_name, "POST")
Esempio n. 18
0
def init_app(app):
    endpoint_name = 'activity'
    service = ActivityService(endpoint_name, backend=superdesk.get_backend())
    ActivityResource(endpoint_name, app=app, service=service)

    endpoint_name = 'audit'
    service = AuditService(endpoint_name, backend=superdesk.get_backend())
    AuditResource(endpoint_name, app=app, service=service)

    app.on_inserted += service.on_generic_inserted
    app.on_updated += service.on_generic_updated
    app.on_deleted_item += service.on_generic_deleted

    # Registering with intrinsic privileges because: A user should be able to mark as read their own notifications.
    superdesk.intrinsic_privilege(resource_name='activity', method=['PATCH'])
Esempio n. 19
0
def init_app(app):
    endpoint_name = 'activity'
    service = ActivityService(endpoint_name, backend=superdesk.get_backend())
    ActivityResource(endpoint_name, app=app, service=service)

    endpoint_name = 'audit'
    service = AuditService(endpoint_name, backend=superdesk.get_backend())
    AuditResource(endpoint_name, app=app, service=service)

    app.on_inserted += service.on_generic_inserted
    app.on_updated += service.on_generic_updated
    app.on_deleted_item += service.on_generic_deleted

    # Registering with intrinsic privileges because: A user should be able to mark as read their own notifications.
    superdesk.intrinsic_privilege(resource_name='activity', method=['PATCH'])
Esempio n. 20
0
def init_app(app) -> None:
    endpoint_name = "fetch"
    service: Any = FetchService(endpoint_name, backend=superdesk.get_backend())
    FetchResource(endpoint_name, app=app, service=service)

    endpoint_name = "duplicate"
    service = DuplicateService(endpoint_name, backend=superdesk.get_backend())
    DuplicateResource(endpoint_name, app=app, service=service)

    endpoint_name = "translate"
    service = TranslateService(endpoint_name, backend=superdesk.get_backend())
    TranslateResource(endpoint_name, app=app, service=service)

    endpoint_name = "copy"
    service = CopyService(endpoint_name, backend=superdesk.get_backend())
    CopyResource(endpoint_name, app=app, service=service)

    endpoint_name = "move"
    service = MoveService(endpoint_name, backend=superdesk.get_backend())
    MoveResource(endpoint_name, app=app, service=service)

    superdesk.privilege(name="fetch",
                        label=lazy_gettext("Fetch Content To a Desk"),
                        description=lazy_gettext("Fetch Content to a Desk"))
    superdesk.privilege(
        name="move",
        label=lazy_gettext("Move Content to another desk"),
        description=lazy_gettext("Move Content to another desk"),
    )
    superdesk.privilege(
        name="duplicate",
        label=lazy_gettext("Duplicate Content within a Desk"),
        description=lazy_gettext("Duplicate Content within a Desk"),
    )
    superdesk.privilege(
        name="translate",
        label=lazy_gettext("Translate Content within a Desk"),
        description=lazy_gettext("Translate Content within a Desk"),
    )
    superdesk.privilege(
        name="send_to_personal",
        label=lazy_gettext("Send Content to Personal desk"),
        description=lazy_gettext("Send Content to Personal desk"),
    )

    superdesk.intrinsic_privilege("copy", method=["POST"])

    archive_copy_init_app(app)
Esempio n. 21
0
def init_app(app):
    endpoint_name = 'users'
    service = DBUsersService(endpoint_name, backend=superdesk.get_backend())
    UsersResource(endpoint_name, app=app, service=service)

    superdesk.privilege(name='users',
                        label='User Management',
                        description='User can manage users.')

    # Registering with intrinsic privileges because: A user should be allowed to update their own profile.
    superdesk.intrinsic_privilege(resource_name='users', method=['PATCH'])

    app.client_config.setdefault('user', {}).update({
        'username_pattern':
        app.config.get('USER_USERNAME_PATTERN'),
    })
Esempio n. 22
0
def init_app(app):
    endpoint_name = "users"
    service = DBUsersService(endpoint_name, backend=superdesk.get_backend())
    UsersResource(endpoint_name, app=app, service=service)

    superdesk.privilege(name="users",
                        label="User Management",
                        description="User can manage users.")

    # Registering with intrinsic privileges because: A user should be allowed to update their own profile.
    superdesk.intrinsic_privilege(resource_name="users", method=["PATCH"])

    app.client_config.setdefault("user", {}).update({
        "username_pattern":
        app.config.get("USER_USERNAME_PATTERN"),
    })
Esempio n. 23
0
def init_app(app):
    if AUTO_IMPORT:
        tools.import_services(app, __name__, AIServiceBase)

    allowed_service = list(registered_ai_services)

    endpoint_name = AI_SERVICE_ENDPOINT
    service = AIService(endpoint_name, backend=superdesk.get_backend())
    AIResource.schema["service"]["allowed"] = allowed_service
    AIResource(endpoint_name, app=app, service=service)
    superdesk.intrinsic_privilege(endpoint_name, method=["POST"])

    endpoint_name = AI_DATA_OP_ENDPOINT
    service = AIDataOpService(endpoint_name, backend=superdesk.get_backend())
    AIDataOpResource.schema["service"]["allowed"] = allowed_service
    AIDataOpResource(endpoint_name, app=app, service=service)
    superdesk.intrinsic_privilege(endpoint_name, method=["POST"])
Esempio n. 24
0
def init_app(app):
    endpoint_name = "users"
    service = ADUsersService(endpoint_name, backend=superdesk.get_backend())
    UsersResource(endpoint_name, app=app, service=service)

    superdesk.privilege(name="users", label="User Management", description="User can manage users.")

    # Registering with intrinsic privileges because: A user should be allowed to update their own profile.
    superdesk.intrinsic_privilege(resource_name="users", method=["PATCH"])

    # we need to use the same endpoint as database auth because it is called in the same location
    endpoint_name = "auth_db"
    service = ADAuthService(endpoint_name, backend=superdesk.get_backend())
    AuthResource(endpoint_name, app=app, service=service)

    endpoint_name = ImportUserProfileResource.url
    service = ImportUserProfileService(endpoint_name, backend=superdesk.get_backend())
    ImportUserProfileResource(endpoint_name, app=app, service=service)
Esempio n. 25
0
def init_app(app):
    """Initialize planning plugin.

    :param app: superdesk app
    """
    planning_search_service = PlanningService('planning',
                                              backend=superdesk.get_backend())
    PlanningResource('planning', app=app, service=planning_search_service)

    planning_lock_service = PlanningLockService(
        'planning_lock', backend=superdesk.get_backend())
    PlanningLockResource('planning_lock',
                         app=app,
                         service=planning_lock_service)

    events_lock_service = EventsLockService('events_lock',
                                            backend=superdesk.get_backend())
    EventsLockResource('events_lock', app=app, service=events_lock_service)

    planning_unlock_service = PlanningUnlockService(
        'planning_unlock', backend=superdesk.get_backend())
    PlanningUnlockResource('planning_unlock',
                           app=app,
                           service=planning_unlock_service)

    events_unlock_service = EventsUnlockService(
        'events_unlock', backend=superdesk.get_backend())
    EventsUnlockResource('events_unlock',
                         app=app,
                         service=events_unlock_service)

    planning_spike_service = PlanningSpikeService(
        'planning_spike', backend=superdesk.get_backend())
    PlanningSpikeResource('planning_spike',
                          app=app,
                          service=planning_spike_service)

    planning_unspike_service = PlanningUnspikeService(
        'planning_unspike', backend=superdesk.get_backend())
    PlanningUnspikeResource('planning_unspike',
                            app=app,
                            service=planning_unspike_service)

    planning_publish_service = PlanningPublishService(
        'planning_publish', backend=superdesk.get_backend())
    PlanningPublishResource('planning_publish',
                            app=app,
                            service=planning_publish_service)

    planning_duplicate_service = PlanningDuplicateService(
        'planning_duplicate', backend=superdesk.get_backend())
    PlanningDuplicateResource('planning_duplicate',
                              app=app,
                              service=planning_duplicate_service)

    agendas_service = AgendasService('agenda', backend=superdesk.get_backend())
    AgendasResource('agenda', app=app, service=agendas_service)

    coverage_search_service = CoverageService('coverage',
                                              backend=superdesk.get_backend())
    CoverageResource('coverage', app=app, service=coverage_search_service)

    events_search_service = EventsService('events',
                                          backend=superdesk.get_backend())
    EventsResource('events', app=app, service=events_search_service)

    events_spike_service = EventsSpikeService('events_spike',
                                              backend=superdesk.get_backend())
    EventsSpikeResource('events_spike', app=app, service=events_spike_service)

    events_unspike_service = EventsUnspikeService(
        'events_unspike', backend=superdesk.get_backend())
    EventsUnspikeResource('events_unspike',
                          app=app,
                          service=events_unspike_service)

    events_publish_service = EventsPublishService(
        'events_publish', backend=superdesk.get_backend())
    EventsPublishResource('events_publish',
                          app=app,
                          service=events_publish_service)

    locations_search_service = LocationsService(
        'locations', backend=superdesk.get_backend())
    LocationsResource('locations', app=app, service=locations_search_service)

    files_service = EventsFilesService('events_files',
                                       backend=superdesk.get_backend())
    EventsFilesResource('events_files', app=app, service=files_service)

    events_history_service = EventsHistoryService(
        'events_history', backend=superdesk.get_backend())
    EventsHistoryResource('events_history',
                          app=app,
                          service=events_history_service)

    planning_type_service = PlanningTypesService(
        PlanningTypesResource.endpoint_name, backend=superdesk.get_backend())
    PlanningTypesResource(PlanningTypesResource.endpoint_name,
                          app=app,
                          service=planning_type_service)

    events_cancel_service = EventsCancelService(
        EventsCancelResource.endpoint_name, backend=superdesk.get_backend())
    EventsCancelResource(EventsCancelResource.endpoint_name,
                         app=app,
                         service=events_cancel_service)

    events_reschedule_service = EventsRescheduleService(
        EventsRescheduleResource.endpoint_name,
        backend=superdesk.get_backend())
    EventsRescheduleResource(EventsRescheduleResource.endpoint_name,
                             app=app,
                             service=events_reschedule_service)

    planning_cancel_service = PlanningCancelService(
        PlanningCancelResource.endpoint_name, backend=superdesk.get_backend())
    PlanningCancelResource(PlanningCancelResource.endpoint_name,
                           app=app,
                           service=planning_cancel_service)

    planning_reschedule_service = PlanningRescheduleService(
        PlanningRescheduleResource.endpoint_name,
        backend=superdesk.get_backend())
    PlanningRescheduleResource(PlanningRescheduleResource.endpoint_name,
                               app=app,
                               service=planning_reschedule_service)

    app.on_updated_events += events_history_service.on_item_updated
    app.on_inserted_events += events_history_service.on_item_created
    app.on_deleted_item_events -= events_history_service.on_item_deleted
    app.on_deleted_item_events += events_history_service.on_item_deleted
    app.on_updated_events_spike += events_history_service.on_spike
    app.on_updated_events_unspike += events_history_service.on_unspike
    app.on_updated_events_cancel += events_history_service.on_cancel
    app.on_updated_events_reschedule += events_history_service.on_reschedule

    planning_history_service = PlanningHistoryService(
        'planning_history', backend=superdesk.get_backend())
    PlanningHistoryResource('planning_history',
                            app=app,
                            service=planning_history_service)

    app.on_inserted_planning += planning_history_service.on_item_created
    app.on_updated_planning += planning_history_service.on_item_updated
    app.on_updated_planning_spike += planning_history_service.on_spike
    app.on_updated_planning_unspike += planning_history_service.on_unspike
    app.on_updated_planning_cancel += planning_history_service.on_cancel
    app.on_updated_planning_reschedule += planning_history_service.on_reschedule

    app.on_locked_planning += planning_search_service.on_locked_planning

    coverage_history_service = CoverageHistoryService(
        'coverage_history', backend=superdesk.get_backend())
    CoverageHistoryResource('coverage_history',
                            app=app,
                            service=coverage_history_service)

    app.on_updated_coverage += coverage_history_service.on_item_updated
    app.on_inserted_coverage += coverage_history_service.on_item_created
    app.on_deleted_item_coverage -= coverage_history_service.on_item_deleted
    app.on_deleted_item_coverage += coverage_history_service.on_item_deleted

    events_duplicate_service = EventsDuplicateService(
        'events_duplicate', backend=superdesk.get_backend())
    EventsDuplicateResource('events_duplicate',
                            app=app,
                            service=events_duplicate_service)

    superdesk.privilege(
        name='planning',
        label='Planning',
        description=
        'Create, update, and delete  events, planning items, and coverages')

    superdesk.privilege(
        name='planning_unlock',
        label='Planning - Unlock events and planning items',
        description='Ability to unlock Events and Planning Items')

    superdesk.privilege(name='planning_agenda_management',
                        label='Planning - Agenda Management',
                        description='Ability to create and modify Agendas')

    superdesk.privilege(name='planning_agenda_spike',
                        label='Planning - Spike Agendas',
                        description='Ability to spike an Agenda')

    superdesk.privilege(name='planning_agenda_unspike',
                        label='Planning - Unspike Agendas',
                        description='Ability to unspike an Agenda')

    superdesk.privilege(
        name='planning_planning_management',
        label='Planning - Planning Item Management',
        description='Ability to create and modify Planning items')

    superdesk.privilege(name='planning_planning_spike',
                        label='Planning - Spike Planning Items',
                        description='Ability to spike a Planning Item')

    superdesk.privilege(name='planning_planning_unspike',
                        label='Planning - Unspike Planning Items',
                        description='Ability to unspike a Planning Item')

    superdesk.privilege(name='planning_event_management',
                        label='Planning - Event Management',
                        description='Ability to create and modify Events')

    superdesk.privilege(name='planning_event_spike',
                        label='Planning - Spike Event Items',
                        description='Ability to spike an Event')

    superdesk.privilege(name='planning_event_unspike',
                        label='Planning - Unspike Event Items',
                        description='Ability to unspike an Event')

    superdesk.intrinsic_privilege(PlanningUnlockResource.endpoint_name,
                                  method=['POST'])
    superdesk.intrinsic_privilege(EventsUnlockResource.endpoint_name,
                                  method=['POST'])

    import planning.output_formatters  # noqa

    app.client_config['max_recurrent_events'] = get_max_recurrent_events(app)
Esempio n. 26
0
def init_app(app):
    endpoint_name = 'validate'
    service = ValidateService(endpoint_name, backend=None)
    ValidateResource(endpoint_name, app=app, service=service)

    superdesk.intrinsic_privilege(resource_name=endpoint_name, method=['POST'])
def init_app(app):
    superdesk.register_resource('config', ConfigResource, ConfigService, _app=app)
    superdesk.intrinsic_privilege('config', method=['POST'])
Esempio n. 28
0
def init_app(app):

    endpoint_name = "ingest"
    service = IngestService(endpoint_name, backend=superdesk.get_backend())
    IngestResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_versions"
    service = ArchiveVersionsService(endpoint_name, backend=superdesk.get_backend())
    ArchiveVersionsResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive"
    service = ArchiveService(endpoint_name, backend=superdesk.get_backend())
    ArchiveResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_media"
    service = ArchiveMediaService(endpoint_name, backend=superdesk.get_backend())
    ArchiveMediaResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_media_versions"
    service = ArchiveVersionsService(endpoint_name, backend=superdesk.get_backend())
    ArchiveMediaVersionsResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_ingest"
    service = ArchiveIngestService(endpoint_name, backend=superdesk.get_backend())
    ArchiveIngestResource(endpoint_name, app=app, service=service)

    endpoint_name = "item_comments"
    service = ItemCommentsService(endpoint_name, backend=superdesk.get_backend())
    ItemCommentsResource(endpoint_name, app=app, service=service)

    endpoint_name = "content_item_comments"
    service = ItemCommentsSubService(endpoint_name, backend=superdesk.get_backend())
    ItemCommentsSubResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_lock"
    service = ArchiveLockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveLockResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_unlock"
    service = ArchiveUnlockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnlockResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_spike"
    service = ArchiveSpikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveSpikeResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_unspike"
    service = ArchiveUnspikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnspikeResource(endpoint_name, app=app, service=service)

    endpoint_name = "user_content"
    service = UserContentService(endpoint_name, backend=superdesk.get_backend())
    UserContentResource(endpoint_name, app=app, service=service)

    endpoint_name = "saved_searches"
    service = SavedSearchesService(endpoint_name, backend=superdesk.get_backend())
    SavedSearchesResource(endpoint_name, app=app, service=service)

    endpoint_name = "saved_search_items"
    service = SavedSearchItemsService(endpoint_name, backend=superdesk.get_backend())
    SavedSearchItemsResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_autosave"
    service = ArchiveSaveService(endpoint_name, backend=superdesk.get_backend())
    AutoSaveResource(endpoint_name, app=app, service=service)

    from apps.item_autosave.components.item_autosave import ItemAutosave
    from apps.item_autosave.models.item_autosave import ItemAutosaveModel

    register_component(ItemLock(app))
    register_component(ItemHold(app))
    register_model(ItemModel(EveProxy(superdesk.get_backend())))
    register_component(ItemAutosave(app))
    register_model(ItemAutosaveModel(EveProxy(superdesk.get_backend())))

    superdesk.privilege(name="archive", label="Archive", description="User can view the published content.")
    superdesk.privilege(name="ingest", label="Ingest", description="User can view content in ingest and fetch it.")
    superdesk.privilege(name="spike", label="Spike", description="User can spike content.")
    superdesk.privilege(name="unspike", label="Un Spike", description="User can un-spike content.")
    superdesk.privilege(name="unlock", label="Unlock content", description="User can unlock content.")
    superdesk.privilege(name="metadata_uniquename", label="Edit Unique Name", description="User can edit unique name.")
    superdesk.privilege(name="ingest_move", label="Move Content To Desk", description="Move Content to a Desk.")
    superdesk.privilege(
        name="saved_searches", label="Manage Saved Searches", description="User can manage Saved Searches"
    )

    superdesk.privilege(name="publish", label="Publish", description="Publish a content")
    superdesk.privilege(name="kill", label="Kill", description="Kill a published content")
    superdesk.privilege(name="correction", label="Correction", description="Correction to a published content")
    superdesk.privilege(name="hold", label="Hold", description="Hold a content")
    superdesk.privilege(name="restore", label="Restore", description="Restore a hold a content")

    superdesk.intrinsic_privilege(ArchiveUnlockResource.endpoint_name, method=["POST"])
Esempio n. 29
0
        },
        'token': {
            'type': 'string'
        },
        'user': Resource.rel('users', True)
    }

    resource_methods = ['POST']
    item_methods = ['GET', 'DELETE']
    public_methods = ['POST', 'DELETE']
    extra_response_fields = ['user', 'token', 'username']
    datasource = {'source': 'auth'}
    mongo_indexes = {'token': ([('token', 1)], {'background': True})}


superdesk.intrinsic_privilege('auth', method=['DELETE'])


class SuperdeskTokenAuth(TokenAuth):
    """Superdesk Token Auth

    """

    def check_permissions(self, resource, method, user):
        """Checks user permissions.

        1. If there's no user associated with the request or HTTP Method is GET then return True.
        2. Get User's Privileges
        3. Intrinsic Privileges:
            Check if resource has intrinsic privileges.
                If it has then check if HTTP Method is allowed.
Esempio n. 30
0
def init_app(app):
    aapmm_datalayer = AAPMMDatalayer(app)
    service = SearchIngestService(datasource=None, backend=aapmm_datalayer, source=PROVIDER_NAME)
    SearchIngestResource(endpoint_name=PROVIDER_NAME, service=service, app=app)
    intrinsic_privilege(resource_name=PROVIDER_NAME, method=['GET', 'POST'])
Esempio n. 31
0
def init_app(app):
    service = AapMMService(datasource=None, backend=app.data.aapmm)
    AapMMResource(endpoint_name='aapmm', app=app, service=service)
    intrinsic_privilege(resource_name='aapmm', method=['GET', 'POST'])
Esempio n. 32
0
def init_app(app):
    app.data.aapmm = AAPMMDatalayer(app)
    service = AapMMService(datasource=None, backend=app.data.aapmm)
    AapMMResource(endpoint_name="aapmm", app=app, service=service)
    intrinsic_privilege(resource_name="aapmm", method=["GET", "POST"])
Esempio n. 33
0
def init_app(app):

    endpoint_name = 'ingest'
    service = IngestService(endpoint_name, backend=superdesk.get_backend())
    IngestResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_versions'
    service = ArchiveVersionsService(endpoint_name,
                                     backend=superdesk.get_backend())
    ArchiveVersionsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive'
    service = ArchiveService(endpoint_name, backend=superdesk.get_backend())
    ArchiveResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_media'
    service = ArchiveMediaService(endpoint_name,
                                  backend=superdesk.get_backend())
    ArchiveMediaResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_media_versions'
    service = ArchiveVersionsService(endpoint_name,
                                     backend=superdesk.get_backend())
    ArchiveMediaVersionsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_ingest'
    service = ArchiveIngestService(endpoint_name,
                                   backend=superdesk.get_backend())
    ArchiveIngestResource(endpoint_name, app=app, service=service)

    endpoint_name = 'item_comments'
    service = ItemCommentsService(endpoint_name,
                                  backend=superdesk.get_backend())
    ItemCommentsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'content_item_comments'
    service = ItemCommentsSubService(endpoint_name,
                                     backend=superdesk.get_backend())
    ItemCommentsSubResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_lock'
    service = ArchiveLockService(endpoint_name,
                                 backend=superdesk.get_backend())
    ArchiveLockResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_unlock'
    service = ArchiveUnlockService(endpoint_name,
                                   backend=superdesk.get_backend())
    ArchiveUnlockResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_spike'
    service = ArchiveSpikeService(endpoint_name,
                                  backend=superdesk.get_backend())
    ArchiveSpikeResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_unspike'
    service = ArchiveUnspikeService(endpoint_name,
                                    backend=superdesk.get_backend())
    ArchiveUnspikeResource(endpoint_name, app=app, service=service)

    endpoint_name = 'user_content'
    service = UserContentService(endpoint_name,
                                 backend=superdesk.get_backend())
    UserContentResource(endpoint_name, app=app, service=service)

    endpoint_name = 'saved_searches'
    service = SavedSearchesService(endpoint_name,
                                   backend=superdesk.get_backend())
    SavedSearchesResource(endpoint_name, app=app, service=service)

    endpoint_name = 'saved_search_items'
    service = SavedSearchItemsService(endpoint_name,
                                      backend=superdesk.get_backend())
    SavedSearchItemsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_autosave'
    service = ArchiveSaveService(endpoint_name,
                                 backend=superdesk.get_backend())
    AutoSaveResource(endpoint_name, app=app, service=service)

    from apps.item_autosave.components.item_autosave import ItemAutosave
    from apps.item_autosave.models.item_autosave import ItemAutosaveModel
    register_component(ItemLock(app))
    register_component(ItemHold(app))
    register_model(ItemModel(EveProxy(superdesk.get_backend())))
    register_component(ItemAutosave(app))
    register_model(ItemAutosaveModel(EveProxy(superdesk.get_backend())))

    superdesk.privilege(name='archive',
                        label='Archive',
                        description='User can view the published content.')
    superdesk.privilege(
        name='ingest',
        label='Ingest',
        description='User can view content in ingest and fetch it.')
    superdesk.privilege(name='spike',
                        label='Spike',
                        description='User can spike content.')
    superdesk.privilege(name='unspike',
                        label='Un Spike',
                        description='User can un-spike content.')
    superdesk.privilege(name='unlock',
                        label='Unlock content',
                        description='User can unlock content.')
    superdesk.privilege(name='metadata_uniquename',
                        label='Edit Unique Name',
                        description='User can edit unique name.')
    superdesk.privilege(name='ingest_move',
                        label='Move Content To Desk',
                        description='Move Content to a Desk.')
    superdesk.privilege(name='saved_searches',
                        label='Manage Saved Searches',
                        description='User can manage Saved Searches')

    superdesk.privilege(name='publish',
                        label='Publish',
                        description='Publish a content')
    superdesk.privilege(name='kill',
                        label='Kill',
                        description='Kill a published content')
    superdesk.privilege(name='correction',
                        label='Correction',
                        description='Correction to a published content')
    superdesk.privilege(name='hold',
                        label='Hold',
                        description='Hold a content')
    superdesk.privilege(name='restore',
                        label='Restore',
                        description='Restore a hold a content')

    superdesk.intrinsic_privilege(ArchiveUnlockResource.endpoint_name,
                                  method=['POST'])
Esempio n. 34
0
def init_app(app):

    endpoint_name = "ingest"
    service = AppIngestService(endpoint_name, backend=superdesk.get_backend())
    IngestResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_versions"
    service = ArchiveVersionsService(endpoint_name,
                                     backend=superdesk.get_backend())
    ArchiveVersionsResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive"
    service = ArchiveService(endpoint_name, backend=superdesk.get_backend())
    ArchiveResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_lock"
    service = ArchiveLockService(endpoint_name,
                                 backend=superdesk.get_backend())
    ArchiveLockResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_unlock"
    service = ArchiveUnlockService(endpoint_name,
                                   backend=superdesk.get_backend())
    ArchiveUnlockResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_spike"
    service = ArchiveSpikeService(endpoint_name,
                                  backend=superdesk.get_backend())
    ArchiveSpikeResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_unspike"
    service = ArchiveUnspikeService(endpoint_name,
                                    backend=superdesk.get_backend())
    ArchiveUnspikeResource(endpoint_name, app=app, service=service)

    endpoint_name = "user_content"
    service = UserContentService(endpoint_name,
                                 backend=superdesk.get_backend())
    UserContentResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_rewrite"
    service = ArchiveRewriteService(endpoint_name,
                                    backend=superdesk.get_backend())
    ArchiveRewriteResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_correction"
    service = ArchiveCorrectionService(endpoint_name,
                                       backend=superdesk.get_backend())
    ArchiveCorrectionResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_autosave"
    service = ArchiveSaveService(endpoint_name,
                                 backend=superdesk.get_backend())
    AutoSaveResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_related"
    service = ArchiveRelatedService(endpoint_name,
                                    backend=superdesk.get_backend())
    ArchiveRelatedResource(endpoint_name, app=app, service=service)

    endpoint_name = "news"
    service = NewsService(endpoint_name, backend=superdesk.get_backend())
    NewsResource(endpoint_name, app=app, service=service)

    from apps.item_autosave.components.item_autosave import ItemAutosave
    from apps.item_autosave.models.item_autosave import ItemAutosaveModel

    register_component(ItemLock(app))
    register_model(ItemModel(EveProxy(superdesk.get_backend())))
    register_component(ItemAutosave(app))
    register_model(ItemAutosaveModel(EveProxy(superdesk.get_backend())))

    superdesk.privilege(
        name="monitoring_view",
        label=_("Monitoring view"),
        description=_("Access to Monitoring view in left toolbar"))
    superdesk.privilege(name="archive",
                        label=_("Create content"),
                        description=_("Create and save content"))
    superdesk.privilege(name="ingest",
                        label=_("Ingest"),
                        description=_("Access to ingest sources management"))
    superdesk.privilege(name="spike",
                        label=_("Spike"),
                        description=_("Spike/delete items"))
    superdesk.privilege(name="spike_read",
                        label=_("Spike view"),
                        description=_("View spiked content"))
    superdesk.privilege(name="unspike",
                        label=_("Unspike"),
                        description=_("Unspike/undelete content"))
    superdesk.privilege(name="metadata_uniquename",
                        label=_("Edit Unique Name"),
                        description=_("Edit unique name"))
    superdesk.privilege(name="hold",
                        label=_("Hold"),
                        description=_("Hold content"))
    superdesk.privilege(name="restore",
                        label=_("Restore"),
                        description=_("Restore content"))
    superdesk.privilege(name="rewrite",
                        label=_("Update"),
                        description=_("Create an update"))
    superdesk.privilege(name="unlock",
                        label=_("Unlock content"),
                        description=_("Unlock locked content by another user"))
    superdesk.privilege(
        name="mark_for_user",
        label=_("Mark items for users"),
        description=_("User can mark or unmark items for other users"),
    )

    superdesk.intrinsic_privilege(ArchiveUnlockResource.endpoint_name,
                                  method=["POST"])
Esempio n. 35
0
def init_app(app):
    """Initialize planning.

    :param app: superdesk app
    """
    planning_service = PlanningService(PlanningResource.endpoint_name, backend=superdesk.get_backend())
    PlanningResource(PlanningResource.endpoint_name, app=app, service=planning_service)

    planning_lock_service = PlanningLockService('planning_lock', backend=superdesk.get_backend())
    PlanningLockResource('planning_lock', app=app, service=planning_lock_service)

    planning_unlock_service = PlanningUnlockService('planning_unlock', backend=superdesk.get_backend())
    PlanningUnlockResource('planning_unlock', app=app, service=planning_unlock_service)

    planning_spike_service = PlanningSpikeService('planning_spike', backend=superdesk.get_backend())
    PlanningSpikeResource('planning_spike', app=app, service=planning_spike_service)

    planning_unspike_service = PlanningUnspikeService('planning_unspike', backend=superdesk.get_backend())
    PlanningUnspikeResource('planning_unspike', app=app, service=planning_unspike_service)

    planning_post_service = PlanningPostService('planning_post', backend=superdesk.get_backend())
    PlanningPostResource('planning_post', app=app, service=planning_post_service)

    planning_duplicate_service = PlanningDuplicateService('planning_duplicate', backend=superdesk.get_backend())
    PlanningDuplicateResource('planning_duplicate', app=app, service=planning_duplicate_service)

    planning_type_service = PlanningTypesService(PlanningTypesResource.endpoint_name,
                                                 backend=superdesk.get_backend())
    PlanningTypesResource(PlanningTypesResource.endpoint_name,
                          app=app,
                          service=planning_type_service)

    planning_cancel_service = PlanningCancelService(PlanningCancelResource.endpoint_name,
                                                    backend=superdesk.get_backend())
    PlanningCancelResource(PlanningCancelResource.endpoint_name,
                           app=app,
                           service=planning_cancel_service)

    planning_reschedule_service = PlanningRescheduleService(
        PlanningRescheduleResource.endpoint_name,
        backend=superdesk.get_backend()
    )
    PlanningRescheduleResource(
        PlanningRescheduleResource.endpoint_name,
        app=app,
        service=planning_reschedule_service
    )

    planning_postpone_service = PlanningPostponeService(PlanningPostponeResource.endpoint_name,
                                                        backend=superdesk.get_backend())
    PlanningPostponeResource(PlanningPostponeResource.endpoint_name,
                             app=app,
                             service=planning_postpone_service)

    planning_history_service = PlanningHistoryService('planning_history', backend=superdesk.get_backend())
    PlanningHistoryResource('planning_history', app=app, service=planning_history_service)

    planning_featured_lock_service = PlanningFeaturedLockService(PlanningFeaturedLockResource.endpoint_name,
                                                                 backend=superdesk.get_backend())
    PlanningFeaturedLockResource(PlanningFeaturedLockResource.endpoint_name, app=app,
                                 service=planning_featured_lock_service)

    planning_featured_unlock_service = PlanningFeaturedUnlockService(PlanningFeaturedUnlockResource.endpoint_name,
                                                                     backend=superdesk.get_backend())
    PlanningFeaturedUnlockResource(PlanningFeaturedUnlockResource.endpoint_name, app=app,
                                   service=planning_featured_unlock_service)

    planning_featured_service = PlanningFeaturedService('planning_featured', backend=superdesk.get_backend())
    PlanningFeaturedResource('planning_featured', app=app, service=planning_featured_service)

    superdesk.register_resource(
        'planning_export',
        PlanningExportResource,
        PlanningExportService,
        privilege='planning',
        _app=app
    )

    planning_autosave_service = AutosaveService('planning_autosave', superdesk.get_backend())
    PlanningAutosaveResource('planning_autosave', app=app, service=planning_autosave_service)

    app.on_inserted_planning += planning_history_service.on_item_created
    app.on_updated_planning += planning_history_service.on_item_updated
    app.on_updated_planning_spike += planning_history_service.on_spike
    app.on_updated_planning_unspike += planning_history_service.on_unspike
    app.on_updated_planning_cancel += planning_history_service.on_cancel
    app.on_updated_planning_reschedule += planning_history_service.on_reschedule
    app.on_updated_planning_postpone += planning_history_service.on_postpone

    app.on_locked_planning += planning_service.on_locked_planning

    app.on_session_end += planning_autosave_service.on_session_end

    superdesk.privilege(
        name='planning_planning_management',
        label='Planning - Planning Item Management',
        description='Ability to create and modify Planning items'
    )

    superdesk.privilege(
        name='planning_planning_spike',
        label='Planning - Spike Planning Items',
        description='Ability to spike a Planning Item'
    )

    superdesk.privilege(
        name='planning_planning_unspike',
        label='Planning - Unspike Planning Items',
        description='Ability to unspike a Planning Item'
    )

    superdesk.privilege(
        name='planning_planning_post',
        label='Planning - Post Planning Items',
        description='Ability to post a Planning Item'
    )

    superdesk.privilege(
        name='planning_planning_unpost',
        label='Planning - Unpost Planning Items',
        description='Ability to unpost a Planning Item'
    )

    superdesk.privilege(
        name='planning_planning_featured',
        label='Planning - Featured Stories',
        description='Ability to create and modify a featured stories list from planning items'
    )

    superdesk.intrinsic_privilege(PlanningUnlockResource.endpoint_name, method=['POST'])
Esempio n. 36
0
def init_app(app):

    endpoint_name = 'ingest'
    service = AppIngestService(endpoint_name, backend=superdesk.get_backend())
    IngestResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_versions'
    service = superdesk.Service(endpoint_name, backend=superdesk.get_backend())
    ArchiveVersionsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive'
    service = ArchiveService(endpoint_name, backend=superdesk.get_backend())
    ArchiveResource(endpoint_name, app=app, service=service)

    endpoint_name = 'item_comments'
    service = ItemCommentsService(endpoint_name, backend=superdesk.get_backend())
    ItemCommentsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'content_item_comments'
    service = ItemCommentsSubService(endpoint_name, backend=superdesk.get_backend())
    ItemCommentsSubResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_lock'
    service = ArchiveLockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveLockResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_unlock'
    service = ArchiveUnlockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnlockResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_spike'
    service = ArchiveSpikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveSpikeResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_unspike'
    service = ArchiveUnspikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnspikeResource(endpoint_name, app=app, service=service)

    endpoint_name = 'user_content'
    service = UserContentService(endpoint_name, backend=superdesk.get_backend())
    UserContentResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_link'
    service = ArchiveLinkService(endpoint_name, backend=superdesk.get_backend())
    ArchiveLinkResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_rewrite'
    service = ArchiveRewriteService(endpoint_name, backend=superdesk.get_backend())
    ArchiveRewriteResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_autosave'
    service = ArchiveSaveService(endpoint_name, backend=superdesk.get_backend())
    AutoSaveResource(endpoint_name, app=app, service=service)

    from apps.item_autosave.components.item_autosave import ItemAutosave
    from apps.item_autosave.models.item_autosave import ItemAutosaveModel
    register_component(ItemLock(app))
    register_component(ItemHold(app))
    register_model(ItemModel(EveProxy(superdesk.get_backend())))
    register_component(ItemAutosave(app))
    register_model(ItemAutosaveModel(EveProxy(superdesk.get_backend())))

    superdesk.privilege(name='archive', label='Archive', description='User can view the published content.')
    superdesk.privilege(name='ingest', label='Ingest', description='User can view content in ingest and fetch it.')
    superdesk.privilege(name='spike', label='Spike', description='User can spike content.')
    superdesk.privilege(name='unspike', label='Un Spike', description='User can un-spike content.')
    superdesk.privilege(name='unlock', label='Unlock content', description='User can unlock content.')
    superdesk.privilege(name='metadata_uniquename', label='Edit Unique Name', description='User can edit unique name.')
    superdesk.privilege(name='hold', label='Hold', description='Hold a content')
    superdesk.privilege(name='restore', label='Restore', description='Restore a hold a content')
    superdesk.privilege(name='rewrite', label='Rewrite', description='Rewrite a published content')

    superdesk.intrinsic_privilege(ArchiveUnlockResource.endpoint_name, method=['POST'])
    superdesk.intrinsic_privilege(ArchiveLinkResource.endpoint_name, method=['POST'])
Esempio n. 37
0
from apps.auth import AuthResource
from .reset_password import ResetPasswordService, ResetPasswordResource, ActiveTokensResource
import superdesk
from .db import DbAuthService
from .commands import CreateUserCommand, HashUserPasswordsCommand  # noqa
from superdesk.services import BaseService
from apps.auth.db.change_password import ChangePasswordService, ChangePasswordResource


def init_app(app):
    endpoint_name = "auth_db"
    service = DbAuthService("auth", backend=superdesk.get_backend())
    AuthResource(endpoint_name, app=app, service=service)

    endpoint_name = "reset_user_password"
    service = ResetPasswordService(endpoint_name,
                                   backend=superdesk.get_backend())
    ResetPasswordResource(endpoint_name, app=app, service=service)

    endpoint_name = "change_user_password"
    service = ChangePasswordService(endpoint_name,
                                    backend=superdesk.get_backend())
    ChangePasswordResource(endpoint_name, app=app, service=service)

    endpoint_name = "active_tokens"
    service = BaseService(endpoint_name, backend=superdesk.get_backend())
    ActiveTokensResource(endpoint_name, app=app, service=service)


superdesk.intrinsic_privilege("auth_db", method=["DELETE"])
Esempio n. 38
0
def init_app(app):
    """Initialize events

    :param app: superdesk app
    """
    events_lock_service = EventsLockService('events_lock',
                                            backend=superdesk.get_backend())
    EventsLockResource('events_lock', app=app, service=events_lock_service)

    events_unlock_service = EventsUnlockService(
        'events_unlock', backend=superdesk.get_backend())
    EventsUnlockResource('events_unlock',
                         app=app,
                         service=events_unlock_service)

    events_search_service = EventsService(EventsResource.endpoint_name,
                                          backend=superdesk.get_backend())
    EventsResource(EventsResource.endpoint_name,
                   app=app,
                   service=events_search_service)

    events_spike_service = EventsSpikeService('events_spike',
                                              backend=superdesk.get_backend())
    EventsSpikeResource('events_spike', app=app, service=events_spike_service)

    events_unspike_service = EventsUnspikeService(
        'events_unspike', backend=superdesk.get_backend())
    EventsUnspikeResource('events_unspike',
                          app=app,
                          service=events_unspike_service)

    events_post_service = EventsPostService('events_post',
                                            backend=superdesk.get_backend())
    EventsPostResource('events_post', app=app, service=events_post_service)

    files_service = EventsFilesService('events_files',
                                       backend=superdesk.get_backend())
    EventsFilesResource('events_files', app=app, service=files_service)

    events_history_service = EventsHistoryService(
        'events_history', backend=superdesk.get_backend())
    EventsHistoryResource('events_history',
                          app=app,
                          service=events_history_service)

    events_cancel_service = EventsCancelService(
        EventsCancelResource.endpoint_name, backend=superdesk.get_backend())
    EventsCancelResource(EventsCancelResource.endpoint_name,
                         app=app,
                         service=events_cancel_service)

    events_reschedule_service = EventsRescheduleService(
        EventsRescheduleResource.endpoint_name,
        backend=superdesk.get_backend())
    EventsRescheduleResource(EventsRescheduleResource.endpoint_name,
                             app=app,
                             service=events_reschedule_service)

    events_postpone_service = EventsPostponeService(
        EventsPostponeResource.endpoint_name, backend=superdesk.get_backend())
    EventsPostponeResource(EventsPostponeResource.endpoint_name,
                           app=app,
                           service=events_postpone_service)

    events_duplicate_service = EventsDuplicateService(
        'events_duplicate', backend=superdesk.get_backend())
    EventsDuplicateResource('events_duplicate',
                            app=app,
                            service=events_duplicate_service)

    events_update_time_service = EventsUpdateTimeService(
        EventsUpdateTimeResource.endpoint_name,
        backend=superdesk.get_backend())
    EventsUpdateTimeResource(EventsUpdateTimeResource.endpoint_name,
                             app=app,
                             service=events_update_time_service)

    events_update_repetitions_service = EventsUpdateRepetitionsService(
        EventsUpdateRepetitionsResource.endpoint_name,
        backend=superdesk.get_backend())
    EventsUpdateRepetitionsResource(
        EventsUpdateRepetitionsResource.endpoint_name,
        app=app,
        service=events_update_repetitions_service)

    event_autosave_service = AutosaveService('event_autosave',
                                             superdesk.get_backend())
    EventAutosaveResource('event_autosave',
                          app=app,
                          service=event_autosave_service)

    events_template_service = EventsTemplateService(
        EventsTemplateResource.endpoint_name, backend=superdesk.get_backend())
    EventsTemplateResource(EventsTemplateResource.endpoint_name,
                           app=app,
                           service=events_template_service)

    recent_events_template_service = RecentEventsTemplateService(
        RecentEventsTemplateResource.endpoint_name,
        backend=superdesk.get_backend())
    EventsTemplateResource(RecentEventsTemplateResource.endpoint_name,
                           app=app,
                           service=recent_events_template_service)

    app.on_updated_events += events_history_service.on_item_updated
    app.on_inserted_events += events_history_service.on_item_created
    app.on_deleted_item_events -= events_history_service.on_item_deleted
    app.on_deleted_item_events += events_history_service.on_item_deleted
    app.on_updated_events_spike += events_history_service.on_spike
    app.on_updated_events_unspike += events_history_service.on_unspike
    app.on_updated_events_cancel += events_history_service.on_cancel
    app.on_updated_events_reschedule += events_history_service.on_reschedule
    app.on_updated_events_postpone += events_history_service.on_postpone
    app.on_updated_events_update_time += events_history_service.on_update_time
    app.on_locked_events += events_search_service.on_locked_event

    app.on_session_end += event_autosave_service.on_session_end

    # Privileges
    superdesk.privilege(
        name='planning_event_management',
        label=lazy_gettext('Planning - Event Management'),
        description=lazy_gettext('Ability to create and modify Events'),
    )

    superdesk.privilege(
        name='planning_event_spike',
        label=lazy_gettext('Planning - Spike Event Items'),
        description=lazy_gettext('Ability to spike an Event'),
    )

    superdesk.privilege(
        name='planning_event_unspike',
        label=lazy_gettext('Planning - Unspike Event Items'),
        description=lazy_gettext('Ability to unspike an Event'),
    )

    superdesk.privilege(
        name='planning_event_post',
        label=lazy_gettext('Planning - Post Event Items'),
        description=lazy_gettext('Ability to post an Event'),
    )

    superdesk.privilege(
        name='planning_event_unpost',
        label=lazy_gettext('Planning - Unpost Event Items'),
        description=lazy_gettext('Ability to unpost an Event'),
    )

    superdesk.privilege(
        name='planning_event_templates',
        label=lazy_gettext('Planning - Event Templates'),
        description=lazy_gettext(
            'Ability to create and manage Event templates'),
    )

    superdesk.intrinsic_privilege(EventsUnlockResource.endpoint_name,
                                  method=['POST'])
Esempio n. 39
0
def init_app(app):
    endpoint_name = 'validate'
    service = ValidateService(endpoint_name, backend=None)
    ValidateResource(endpoint_name, app=app, service=service)

    superdesk.intrinsic_privilege(resource_name=endpoint_name, method=['POST'])
Esempio n. 40
0
def init_app(app):
    superdesk.register_resource("config",
                                ConfigResource,
                                ConfigService,
                                _app=app)
    superdesk.intrinsic_privilege("config", method=["POST"])
Esempio n. 41
0
        'password': {
            'type': 'string',
            'required': True
        },
        'token': {
            'type': 'string'
        },
        'user': Resource.rel('users', True)
    }
    resource_methods = ['POST']
    item_methods = ['GET', 'DELETE']
    public_methods = ['POST', 'DELETE']
    extra_response_fields = ['user', 'token', 'username']


superdesk.intrinsic_privilege('auth', method=['DELETE'])


class SuperdeskTokenAuth(TokenAuth):
    """Superdesk Token Auth

    """
    def check_permissions(self, resource, method, user):
        """Checks user permissions.

        1. If there's no user associated with the request or HTTP Method is GET then return True.
        2. Get User's Privileges
        3. Intrinsic Privileges:
            Check if resource has intrinsic privileges.
                If it has then check if HTTP Method is allowed.
                    Return True if `is_authorized()` on the resource service returns True.
Esempio n. 42
0
def init_app(app):
    superdesk.register_resource('config',
                                ConfigResource,
                                ConfigService,
                                _app=app)
    superdesk.intrinsic_privilege('config', method=['POST'])
Esempio n. 43
0
def init_app(app):

    endpoint_name = 'ingest'
    service = IngestService(endpoint_name, backend=superdesk.get_backend())
    IngestResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_versions'
    service = superdesk.Service(endpoint_name, backend=superdesk.get_backend())
    ArchiveVersionsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive'
    service = ArchiveService(endpoint_name, backend=superdesk.get_backend())
    ArchiveResource(endpoint_name, app=app, service=service)

    endpoint_name = 'item_comments'
    service = ItemCommentsService(endpoint_name, backend=superdesk.get_backend())
    ItemCommentsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'content_item_comments'
    service = ItemCommentsSubService(endpoint_name, backend=superdesk.get_backend())
    ItemCommentsSubResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_lock'
    service = ArchiveLockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveLockResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_unlock'
    service = ArchiveUnlockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnlockResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_spike'
    service = ArchiveSpikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveSpikeResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_unspike'
    service = ArchiveUnspikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnspikeResource(endpoint_name, app=app, service=service)

    endpoint_name = 'user_content'
    service = UserContentService(endpoint_name, backend=superdesk.get_backend())
    UserContentResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_link'
    service = ArchiveLinkService(endpoint_name, backend=superdesk.get_backend())
    ArchiveLinkResource(endpoint_name, app=app, service=service)

    endpoint_name = 'saved_searches'
    service = SavedSearchesService(endpoint_name, backend=superdesk.get_backend())
    SavedSearchesResource(endpoint_name, app=app, service=service)

    endpoint_name = 'saved_search_items'
    service = SavedSearchItemsService(endpoint_name, backend=superdesk.get_backend())
    SavedSearchItemsResource(endpoint_name, app=app, service=service)

    endpoint_name = 'archive_autosave'
    service = ArchiveSaveService(endpoint_name, backend=superdesk.get_backend())
    AutoSaveResource(endpoint_name, app=app, service=service)

    from apps.item_autosave.components.item_autosave import ItemAutosave
    from apps.item_autosave.models.item_autosave import ItemAutosaveModel
    register_component(ItemLock(app))
    register_component(ItemHold(app))
    register_model(ItemModel(EveProxy(superdesk.get_backend())))
    register_component(ItemAutosave(app))
    register_model(ItemAutosaveModel(EveProxy(superdesk.get_backend())))

    superdesk.privilege(name='archive', label='Archive', description='User can view the published content.')
    superdesk.privilege(name='ingest', label='Ingest', description='User can view content in ingest and fetch it.')
    superdesk.privilege(name='spike', label='Spike', description='User can spike content.')
    superdesk.privilege(name='unspike', label='Un Spike', description='User can un-spike content.')
    superdesk.privilege(name='unlock', label='Unlock content', description='User can unlock content.')
    superdesk.privilege(name='metadata_uniquename', label='Edit Unique Name', description='User can edit unique name.')
    superdesk.privilege(name='saved_searches', label='Manage Saved Searches',
                        description='User can manage Saved Searches')

    superdesk.privilege(name='kill', label='Kill', description='Kill a published content')
    superdesk.privilege(name='correct', label='Correction', description='Correction to a published content')
    superdesk.privilege(name='hold', label='Hold', description='Hold a content')
    superdesk.privilege(name='restore', label='Restore', description='Restore a hold a content')

    superdesk.intrinsic_privilege(ArchiveUnlockResource.endpoint_name, method=['POST'])
    superdesk.intrinsic_privilege(ArchiveLinkResource.endpoint_name, method=['POST'])
Esempio n. 44
0
def init_app(app):

    endpoint_name = "ingest"
    service = AppIngestService(endpoint_name, backend=superdesk.get_backend())
    IngestResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_versions"
    service = superdesk.Service(endpoint_name, backend=superdesk.get_backend())
    ArchiveVersionsResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive"
    service = ArchiveService(endpoint_name, backend=superdesk.get_backend())
    ArchiveResource(endpoint_name, app=app, service=service)

    endpoint_name = "item_comments"
    service = ItemCommentsService(endpoint_name, backend=superdesk.get_backend())
    ItemCommentsResource(endpoint_name, app=app, service=service)

    endpoint_name = "content_item_comments"
    service = ItemCommentsSubService(endpoint_name, backend=superdesk.get_backend())
    ItemCommentsSubResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_lock"
    service = ArchiveLockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveLockResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_unlock"
    service = ArchiveUnlockService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnlockResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_spike"
    service = ArchiveSpikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveSpikeResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_unspike"
    service = ArchiveUnspikeService(endpoint_name, backend=superdesk.get_backend())
    ArchiveUnspikeResource(endpoint_name, app=app, service=service)

    endpoint_name = "user_content"
    service = UserContentService(endpoint_name, backend=superdesk.get_backend())
    UserContentResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_link"
    service = ArchiveLinkService(endpoint_name, backend=superdesk.get_backend())
    ArchiveLinkResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_rewrite"
    service = ArchiveRewriteService(endpoint_name, backend=superdesk.get_backend())
    ArchiveRewriteResource(endpoint_name, app=app, service=service)

    endpoint_name = "archive_autosave"
    service = ArchiveSaveService(endpoint_name, backend=superdesk.get_backend())
    AutoSaveResource(endpoint_name, app=app, service=service)

    from apps.item_autosave.components.item_autosave import ItemAutosave
    from apps.item_autosave.models.item_autosave import ItemAutosaveModel

    register_component(ItemLock(app))
    register_component(ItemHold(app))
    register_model(ItemModel(EveProxy(superdesk.get_backend())))
    register_component(ItemAutosave(app))
    register_model(ItemAutosaveModel(EveProxy(superdesk.get_backend())))

    superdesk.privilege(name="archive", label="Archive", description="User can view the published content.")
    superdesk.privilege(name="ingest", label="Ingest", description="User can view content in ingest and fetch it.")
    superdesk.privilege(name="spike", label="Spike", description="User can spike content.")
    superdesk.privilege(name="unspike", label="Un Spike", description="User can un-spike content.")
    superdesk.privilege(name="unlock", label="Unlock content", description="User can unlock content.")
    superdesk.privilege(name="metadata_uniquename", label="Edit Unique Name", description="User can edit unique name.")
    superdesk.privilege(name="hold", label="Hold", description="Hold a content")
    superdesk.privilege(name="restore", label="Restore", description="Restore a hold a content")
    superdesk.privilege(name="rewrite", label="Update", description="Update a published content")

    superdesk.intrinsic_privilege(ArchiveUnlockResource.endpoint_name, method=["POST"])
    superdesk.intrinsic_privilege(ArchiveLinkResource.endpoint_name, method=["POST"])