Skip to content

Commit

Permalink
feat: Remove warnings for LimeSurvey 6.0 features
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Apr 4, 2023
1 parent 2118c1f commit 6f61afa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docker-compose.ref.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
limesurvey:
image: edgarrmondragon/limesurvey
build:
context: ${LS_DOCKERFILE_CONTEXT:-https://github.com/martialblog/docker-limesurvey.git#master:5.0/apache}
context: ${LS_DOCKERFILE_CONTEXT:-https://github.com/martialblog/docker-limesurvey.git#master:6.0/apache}
dockerfile: ${LS_DOCKERFILE:-Dockerfile}
args:
version: ${LS_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
limesurvey:
image: martialblog/limesurvey:${LS_IMAGE_TAG:-5-apache}
image: martialblog/limesurvey:${LS_IMAGE_TAG:-6-apache}
volumes:
- "surveys:/var/www/html/upload/surveys"
- "apache:/var/log/apache2"
Expand Down
30 changes: 20 additions & 10 deletions docs/_ext/limesurvey_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
if TYPE_CHECKING:
from sphinx.application import Sphinx

__all__ = ["ReleasedFeature", "UnreleasedFeature", "setup"]


class UnreleasedFeature(Directive):
"""A directive for development-only features.
Expand All @@ -19,23 +21,31 @@ class UnreleasedFeature(Directive):
"""

required_arguments = 1
message = (
"This method is only supported in LimeSurvey >= {next_version} "
"(currently in development)."
)
admonition_type = nodes.warning

def run(self) -> list[nodes.Node]:
next_version = self.arguments[0]
admonition_node = nodes.warning(
"",
nodes.paragraph(
text=(
f"This method is only available in LimeSurvey >= {next_version} "
"(currently in development)."
),
),
)
return [admonition_node]
text = self.message.format(next_version=next_version)
return [self.admonition_type("", nodes.paragraph(text=text))]


class ReleasedFeature(UnreleasedFeature):
"""A directive for released features.
Adds a note to features only available after some release of LimeSurvey.
"""

message = "This method is only supported in LimeSurvey >= {next_version}."
admonition_type = nodes.note


def setup(app: Sphinx) -> dict[str, Any]:
app.add_directive("future", UnreleasedFeature)
app.add_directive("minlimesurvey", ReleasedFeature)

return {
"version": "0.1",
Expand Down
17 changes: 6 additions & 11 deletions src/citric/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import requests

from citric import enums
from citric._compat import future
from citric.session import Session

if TYPE_CHECKING:
Expand Down Expand Up @@ -228,7 +227,6 @@ def add_participants(
create_tokens,
)

@future("6.0")
def add_quota(
self,
survey_id: int,
Expand Down Expand Up @@ -259,7 +257,7 @@ def add_quota(
ID of the newly created quota.
.. versionadded:: 0.6.0
.. future:: 6.0
.. minlimesurvey:: 6.0.0
"""
return self.session.add_quota(
survey_id,
Expand Down Expand Up @@ -512,7 +510,6 @@ def delete_language(self, survey_id: int, language: str) -> types.OperationStatu
"""
return self.__session.delete_language(survey_id, language)

@future("6.0")
def delete_quota(self, quota_id: int) -> types.OperationStatus:
"""Delete a LimeSurvey quota.
Expand All @@ -523,7 +520,7 @@ def delete_quota(self, quota_id: int) -> types.OperationStatus:
True if the quota was deleted.
.. versionadded:: 0.6.0
.. future:: 6.0
.. minlimesurvey:: 6.0.0
"""
return self.session.delete_quota(quota_id)

Expand Down Expand Up @@ -851,7 +848,6 @@ def get_question_properties(
"""
return self.__session.get_question_properties(question_id, settings, language)

@future("6.0")
def get_quota_properties(
self,
quota_id: int,
Expand All @@ -869,7 +865,7 @@ def get_quota_properties(
Quota properties.
.. versionadded:: 0.6.0
.. future:: 6.0
.. minlimesurvey:: 6.0.0
"""
return self.session.get_quota_properties(quota_id, settings, language)

Expand All @@ -889,15 +885,15 @@ def get_response_ids(
"""
return self.__session.get_response_ids(survey_id, token)

@future("6.0")
def get_available_site_settings(self) -> list[str]:
"""Get all available site settings.
Returns:
A list of all the available site settings.
.. versionadded:: 0.6.0
.. future:: 6.0
.. future: 6.0.0
.. minlimesurvey:: 6.0.0
"""
return self.session.get_available_site_settings()

Expand Down Expand Up @@ -1216,7 +1212,6 @@ def list_questions(
"""
return self.__session.list_questions(survey_id, group_id, language)

@future("6.0")
def list_quotas(self, survey_id: int) -> list[types.QuotaListElement]:
"""Get all quotas for a LimeSurvey survey.
Expand All @@ -1227,7 +1222,7 @@ def list_quotas(self, survey_id: int) -> list[types.QuotaListElement]:
List of quotas.
.. versionadded:: 0.6.0
.. future:: 6.0
.. minlimesurvey:: 6.0.0
"""
return self.session.list_quotas(survey_id)

Expand Down
2 changes: 0 additions & 2 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def test_question(client: citric.Client, survey_id: int):


@pytest.mark.integration_test
@pytest.mark.version("develop")
def test_quota(client: citric.Client, survey_id: int):
"""Test quota methods."""
with pytest.raises(LimeSurveyStatusError, match="No quotas found"):
Expand Down Expand Up @@ -488,7 +487,6 @@ def test_file_upload_invalid_extension(


@pytest.mark.integration_test
@pytest.mark.version("develop")
def test_get_available_site_settings(client: citric.Client):
"""Test getting available site settings."""
assert client.get_available_site_settings()
Expand Down

0 comments on commit 6f61afa

Please sign in to comment.