Skip to content

Commit

Permalink
"Add behavior: ExtSamplePoint"
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunga001 committed Aug 29, 2024
1 parent 66d6c14 commit b42e2e4
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build new docker image

on:
# Triggers the workflow on push or pull request events but only for the 2.x branch
push:
branches: [ 2.x ]
# pull_request:
# branches: [ 2.x ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: 'ubuntu-latest'

# Steps represent a sequence of tasks that will be executed as part of the job
steps:

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Show workspace
run: echo ${{ github.workspace }}

- name: Checkout senaite.docker
uses: actions/checkout@v3
with:
repository: "senaite/senaite.docker"
path: "senaite.docker"

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: ${{ github.workspace }}/senaite.docker/latest
file: ${{ github.workspace }}/senaite.docker/latest/Dockerfile
no-cache: true
push: true
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
tags: senaite/senaite:edge,senaite/senaite:${{ github.ref_name }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
Empty file.
22 changes: 22 additions & 0 deletions src/bika/aquaculture/behaviors/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone">

<include package="plone.behavior" file="meta.zcml"/>

<!-- -*- extra stuff goes here -*- -->

<plone:behavior
name="bika.aquaculture.ext_sample_point"
title="ExtSamplePoint"
description="Extends/Customises Sample Point"
provides=".ext_sample_point.IExtSamplePoint"
factory=".ext_sample_point.ExtSamplePoint"
marker=".ext_sample_point.IExtSamplePointMarker"
/>


</configure>
44 changes: 44 additions & 0 deletions src/bika/aquaculture/behaviors/ext_sample_point.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-

from bika.aquaculture import _
from plone import schema
from plone.autoform.interfaces import IFormFieldProvider
from plone.supermodel import model
from Products.CMFPlone.utils import safe_hasattr
from zope.component import adapter
from zope.interface import Interface
from zope.interface import implementer
from zope.interface import provider


class IExtSamplePointMarker(Interface):
pass


@provider(IFormFieldProvider)
class IExtSamplePoint(model.Schema):
"""
"""

project = schema.TextLine(
title=_(u'Project'),
description=_(u'Give in a project name'),
required=False,
)


@implementer(IExtSamplePoint)
@adapter(IExtSamplePointMarker)
class ExtSamplePoint(object):
def __init__(self, context):
self.context = context

@property
def project(self):
if safe_hasattr(self.context, 'project'):
return self.context.project
return None

@project.setter
def project(self, value):
self.context.project = value
Binary file not shown.
3 changes: 3 additions & 0 deletions src/bika/aquaculture/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
/>

<!-- -*- extra stuff goes here -*- -->

<include package=".behaviors" />

<plone:static directory="reports" type="senaite.impress.reports"/>

</configure>
26 changes: 26 additions & 0 deletions src/bika/aquaculture/tests/test_behavior_ext_sample_point.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from bika.aquaculture.behaviors.ext_sample_point import IExtSamplePointMarker
from bika.aquaculture.testing import BIKA_AQUACULTURE_INTEGRATION_TESTING # noqa
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.behavior.interfaces import IBehavior
from zope.component import getUtility

import unittest


class ExtSamplePointIntegrationTest(unittest.TestCase):

layer = BIKA_AQUACULTURE_INTEGRATION_TESTING

def setUp(self):
"""Custom shared utility setup for tests."""
self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager'])

def test_behavior_ext_sample_point(self):
behavior = getUtility(IBehavior, 'bika.aquaculture.ext_sample_point')
self.assertEqual(
behavior.marker,
IExtSamplePointMarker,
)

0 comments on commit b42e2e4

Please sign in to comment.