From 3e482d2e4999a159c9160c4391498068ce751f15 Mon Sep 17 00:00:00 2001 From: Jan Dickmann Date: Sun, 30 Jun 2024 12:40:39 +0200 Subject: [PATCH 1/3] dockerfile, fixing hardcoded url and cleanup --- slaeforms/app.py | 5 +- slaeforms/dockerfile | 17 ++ slaeforms/requirements.txt | 16 + slaeforms/templates/layout2.html | 126 ++++---- slaeforms/templates/login.html | 2 +- .../{ => old_unused}/myvideotemplate.html | 282 +++++++++--------- slaeforms/templates/popuptest.html | 2 +- slaeforms/templates/standard_template.html | 2 +- slaeforms/templates/startpage.html | 2 +- slaeforms/templates/test_page0.html | 20 -- slaeforms/templates/test_page1.html | 25 -- slaeforms/templates/teststartpage.html | 2 +- 12 files changed, 246 insertions(+), 255 deletions(-) create mode 100644 slaeforms/dockerfile create mode 100644 slaeforms/requirements.txt rename slaeforms/templates/{ => old_unused}/myvideotemplate.html (97%) delete mode 100644 slaeforms/templates/test_page0.html delete mode 100644 slaeforms/templates/test_page1.html diff --git a/slaeforms/app.py b/slaeforms/app.py index a02f65c..034256e 100644 --- a/slaeforms/app.py +++ b/slaeforms/app.py @@ -657,5 +657,8 @@ def delete_all_entries(): # Close the session db.session.close() +def create_app(): + return app + if __name__ == '__main__': - app.run() \ No newline at end of file + app.run() diff --git a/slaeforms/dockerfile b/slaeforms/dockerfile new file mode 100644 index 0000000..a3153c4 --- /dev/null +++ b/slaeforms/dockerfile @@ -0,0 +1,17 @@ +# Use the official Python image from the Docker Hub +FROM python:3.10-slim + +# Set the working directory +WORKDIR /slaeforms + +# Copy the rest of the application code to the working directory +COPY . . + +# Install the dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Expose the port on which the app will run +EXPOSE 8000 + +# Define the command to run the application using Gunicorn +CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app:create_app()"] \ No newline at end of file diff --git a/slaeforms/requirements.txt b/slaeforms/requirements.txt new file mode 100644 index 0000000..457a64d --- /dev/null +++ b/slaeforms/requirements.txt @@ -0,0 +1,16 @@ +blinker==1.8.2 +click==8.1.7 +colorama==0.4.6 +Flask==3.0.3 +Flask-SQLAlchemy==3.1.1 +Flask-WTF==1.2.1 +greenlet==3.0.3 +gunicorn==22.0.0 +itsdangerous==2.2.0 +Jinja2==3.1.4 +MarkupSafe==2.1.5 +packaging==24.1 +SQLAlchemy==2.0.30 +typing_extensions==4.12.2 +Werkzeug==3.0.3 +WTForms==3.1.2 diff --git a/slaeforms/templates/layout2.html b/slaeforms/templates/layout2.html index f3154dc..d73ce1a 100644 --- a/slaeforms/templates/layout2.html +++ b/slaeforms/templates/layout2.html @@ -1,64 +1,64 @@ - - - - - - - Testform - - - - -

Question: {{ current_question }}

- {% if (videotype == "single")%} -
-

Video 1

- -
- {% elif (videotype == "pairwise")%} -
-
-

Video 1

- -
-
-

Video 2

- -
-
- - {% else %} -

Error: No Videotype could be matched or was given!

- {% endif %} -
- {% for block in config["question 1"]["blocks"] %} - {% if (config["question 1"]["blocks"][block]["type"] == "likert") %} -
-
- - - - - -
-
- {% elif (config["question 1"]["blocks"][block]["type"] == "textinput") %} - - - {% else %} -

Error: A block could not be loaded!

- {% endif %} - {% endfor %} -

-
- - + + + + + + + Testform + + + + +

Question: {{ current_question }}

+ {% if (videotype == "single")%} +
+

Video 1

+ +
+ {% elif (videotype == "pairwise")%} +
+
+

Video 1

+ +
+
+

Video 2

+ +
+
+ + {% else %} +

Error: No Videotype could be matched or was given!

+ {% endif %} +
+ {% for block in config["question 1"]["blocks"] %} + {% if (config["question 1"]["blocks"][block]["type"] == "likert") %} +
+
+ + + + + +
+
+ {% elif (config["question 1"]["blocks"][block]["type"] == "textinput") %} + + + {% else %} +

Error: A block could not be loaded!

+ {% endif %} + {% endfor %} +

+
+ + \ No newline at end of file diff --git a/slaeforms/templates/login.html b/slaeforms/templates/login.html index 6c2bf6a..6fc1cc1 100644 --- a/slaeforms/templates/login.html +++ b/slaeforms/templates/login.html @@ -12,7 +12,7 @@
diff --git a/slaeforms/templates/myvideotemplate.html b/slaeforms/templates/old_unused/myvideotemplate.html similarity index 97% rename from slaeforms/templates/myvideotemplate.html rename to slaeforms/templates/old_unused/myvideotemplate.html index 6e3cbf4..608dca2 100644 --- a/slaeforms/templates/myvideotemplate.html +++ b/slaeforms/templates/old_unused/myvideotemplate.html @@ -1,142 +1,142 @@ - - - - - - - - Testform - - - - -
-

Gib Feedback als Video

-
- - - -
- -
- - - - - -
- -
- -
- -
- - + + + + + + + + Testform + + + + +
+

Gib Feedback als Video

+
+ + + +
+ +
+ + + + + +
+ +
+ +
+ +
+ + \ No newline at end of file diff --git a/slaeforms/templates/popuptest.html b/slaeforms/templates/popuptest.html index 11920b0..176f923 100644 --- a/slaeforms/templates/popuptest.html +++ b/slaeforms/templates/popuptest.html @@ -39,7 +39,7 @@ If you have further questions, please send an email to testemail@notarealemail.deee

-
+ diff --git a/slaeforms/templates/standard_template.html b/slaeforms/templates/standard_template.html index 02c0c9c..967a75a 100644 --- a/slaeforms/templates/standard_template.html +++ b/slaeforms/templates/standard_template.html @@ -123,7 +123,7 @@ step={{question["step"]}}

Error: Block {{ stimulus["type"] }} could not be loaded!

{% endif %} - + {% for question in questions %} {% if (questions[question]["type"] == "likert") %} diff --git a/slaeforms/templates/startpage.html b/slaeforms/templates/startpage.html index 3de6867..a1c6296 100644 --- a/slaeforms/templates/startpage.html +++ b/slaeforms/templates/startpage.html @@ -10,7 +10,7 @@

Hello! Thank you for participating in our study!

- + diff --git a/slaeforms/templates/test_page0.html b/slaeforms/templates/test_page0.html deleted file mode 100644 index d8c16d6..0000000 --- a/slaeforms/templates/test_page0.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - Test Page 0 - Nothing - - - - -
-

This is just a test page for the single page option of the json configuration, but without something to submit

- - - - -
- - \ No newline at end of file diff --git a/slaeforms/templates/test_page1.html b/slaeforms/templates/test_page1.html deleted file mode 100644 index f3d4611..0000000 --- a/slaeforms/templates/test_page1.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - Test Page 1 - Datenschutzerklaerung - - - - -
-

This is just a test page for the single page option of the json configuration

-
- - -

-
-
- - \ No newline at end of file diff --git a/slaeforms/templates/teststartpage.html b/slaeforms/templates/teststartpage.html index 25eb62d..ffeba3f 100644 --- a/slaeforms/templates/teststartpage.html +++ b/slaeforms/templates/teststartpage.html @@ -32,7 +32,7 @@

-
+ From a75efd7a5fdf5a7b75b097d6a0c78c498fe91e0e Mon Sep 17 00:00:00 2001 From: Jan Dickmann Date: Sun, 30 Jun 2024 12:48:12 +0200 Subject: [PATCH 2/3] Docker Instructions in readme --- README.md | 91 +------------------ ...6_Block 2_video_2_2024.06.27 13-04-37.webm | 0 2 files changed, 3 insertions(+), 88 deletions(-) delete mode 100644 slaeforms/uploads/b8819ad7-845f-4a37-be65-b5935dcdd116_Block 2_video_2_2024.06.27 13-04-37.webm diff --git a/README.md b/README.md index 7d73686..8476ed3 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,8 @@ # masterproject +build the dockerfile with: docker build -t slaeforms . -## Getting started +run the container on port 8000 with: docker run -d -p 8000:8000 slaeforms -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.com/JanDickmann/masterproject.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.com/JanDickmann/masterproject/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +export the container: docker save -o slaeforms.tar slaforms:latest \ No newline at end of file diff --git a/slaeforms/uploads/b8819ad7-845f-4a37-be65-b5935dcdd116_Block 2_video_2_2024.06.27 13-04-37.webm b/slaeforms/uploads/b8819ad7-845f-4a37-be65-b5935dcdd116_Block 2_video_2_2024.06.27 13-04-37.webm deleted file mode 100644 index e69de29..0000000 From 3918d81495c326b544847f31356fcedd88548151 Mon Sep 17 00:00:00 2001 From: Jan Dickmann Date: Sun, 30 Jun 2024 12:48:35 +0200 Subject: [PATCH 3/3] gitignore uploads --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 6178e7c..b2318ae 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ __pycache__/ instance/ +uploads/ + .pytest_cache/ .coverage htmlcov/