diff --git a/.gitignore b/.gitignore index a13fbeb175f3797acac63647a3c3532892982262..c2160eee7e2798a0e547d14e541a49f8079ca054 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,16 @@ uploads/ MisplaceAI/rules/migrations/0001_initial.py MisplaceAI/rules/migrations/__pycache__/0001_initial.cpython-310.pyc MisplaceAI/models +MisplaceAI/rules/__pycache__/views.cpython-310.pyc +MisplaceAI/rules/__pycache__/urls.cpython-310.pyc +MisplaceAI/rules/__pycache__/urls.cpython-310.pyc +MisplaceAI/authentication/__pycache__/views.cpython-310.pyc +MisplaceAI/authentication/__pycache__/urls.cpython-310.pyc +MisplaceAI/models +MisplaceAI/rules/__pycache__/views.cpython-310.pyc +MisplaceAI/rules/__pycache__/urls.cpython-310.pyc +MisplaceAI/rules/__pycache__/models.cpython-310.pyc +MisplaceAI/MisplaceAI/__pycache__/urls.cpython-310.pyc +MisplaceAI/MisplaceAI/__pycache__/settings.cpython-310.pyc +MisplaceAI/authentication/__pycache__/views.cpython-310.pyc +MisplaceAI/authentication/__pycache__/urls.cpython-310.pyc diff --git a/MisplaceAI/MisplaceAI/__pycache__/settings.cpython-310.pyc b/MisplaceAI/MisplaceAI/__pycache__/settings.cpython-310.pyc index 02813be6beff5c02754f819d73ecadb2a17f005a..80a8377dba5af81f9aa86d64f023c5041bce6b2d 100644 Binary files a/MisplaceAI/MisplaceAI/__pycache__/settings.cpython-310.pyc and b/MisplaceAI/MisplaceAI/__pycache__/settings.cpython-310.pyc differ diff --git a/MisplaceAI/MisplaceAI/__pycache__/settings.cpython-39.pyc b/MisplaceAI/MisplaceAI/__pycache__/settings.cpython-39.pyc index 31df9d414c9434dccb4753594eba6ed710b7b5d4..e354b3535587e6b0a382605f7a21074c67abab3a 100644 Binary files a/MisplaceAI/MisplaceAI/__pycache__/settings.cpython-39.pyc and b/MisplaceAI/MisplaceAI/__pycache__/settings.cpython-39.pyc differ diff --git a/MisplaceAI/MisplaceAI/__pycache__/urls.cpython-310.pyc b/MisplaceAI/MisplaceAI/__pycache__/urls.cpython-310.pyc index 3269e3e4f24d50ce020e28131d18a731824bf4cb..cdc9cd3891b702d444c3b2e49a6e851499e9b4e3 100644 Binary files a/MisplaceAI/MisplaceAI/__pycache__/urls.cpython-310.pyc and b/MisplaceAI/MisplaceAI/__pycache__/urls.cpython-310.pyc differ diff --git a/MisplaceAI/MisplaceAI/test_settings.py b/MisplaceAI/MisplaceAI/test_settings.py new file mode 100644 index 0000000000000000000000000000000000000000..f1f30e949b7458cc19b65950c1b000c0a7041634 --- /dev/null +++ b/MisplaceAI/MisplaceAI/test_settings.py @@ -0,0 +1,58 @@ +from .settings import * + +# Database configuration for testing +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'misplaceai_test', + 'USER': 'user', + 'PASSWORD': 'password', + 'HOST': 'db', + 'PORT': '3306', + } +} + +# Use a faster password hasher for tests +PASSWORD_HASHERS = [ + 'django.contrib.auth.hashers.MD5PasswordHasher', +] + +# Use in-memory file storage for faster tests +DEFAULT_FILE_STORAGE = 'inmemorystorage.InMemoryStorage' + +# Test runner configuration +TEST_RUNNER = 'django.test.runner.DiscoverRunner' + +# Disable migrations during tests +class DisableMigrations: + def __contains__(self, item): + return True + + def __getitem__(self, item): + return 'notmigrations' + +MIGRATION_MODULES = DisableMigrations() + +# Static files configuration for testing +STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' + +# Media files configuration for testing +MEDIA_ROOT = os.path.join(BASE_DIR, 'test_media') + +# Additional settings for testing +DEBUG = True +TEMPLATE_DEBUG = True + +# Ensure the tests use a different cache +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + } +} + +# Celery configuration for testing +CELERY_TASK_ALWAYS_EAGER = True +CELERY_TASK_EAGER_PROPAGATES = True + +# Disable Django's email backend during tests +EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend' diff --git a/MisplaceAI/authentication/__pycache__/urls.cpython-310.pyc b/MisplaceAI/authentication/__pycache__/urls.cpython-310.pyc index b79f85e6c3da732f08f20763d8d9dd4f9f58c0c9..3c67b4d1950bff467011ba05fb7a431662f62329 100644 Binary files a/MisplaceAI/authentication/__pycache__/urls.cpython-310.pyc and b/MisplaceAI/authentication/__pycache__/urls.cpython-310.pyc differ diff --git a/MisplaceAI/authentication/__pycache__/views.cpython-310.pyc b/MisplaceAI/authentication/__pycache__/views.cpython-310.pyc index 0f3a5bf6b0e6ff587ef4c85fae26f30fe63f9f50..a09863931515576a4e71ad91083391430a224427 100644 Binary files a/MisplaceAI/authentication/__pycache__/views.cpython-310.pyc and b/MisplaceAI/authentication/__pycache__/views.cpython-310.pyc differ diff --git a/MisplaceAI/pytest.ini b/MisplaceAI/pytest.ini new file mode 100644 index 0000000000000000000000000000000000000000..981b79b95e209eaf20014f48c55937978e924c32 --- /dev/null +++ b/MisplaceAI/pytest.ini @@ -0,0 +1,6 @@ +[pytest] +DJANGO_SETTINGS_MODULE = MisplaceAI.settings +addopts = -v --ignore=MisplaceAI/models +testpaths = + rules/tests + diff --git a/MisplaceAI/requirements.txt b/MisplaceAI/requirements.txt index 1d8de2a3338503d89137b6ca5475623760444b88..cf34eaace35f645a5c9ffc8c7c1beeb0d5ee9c38 100644 --- a/MisplaceAI/requirements.txt +++ b/MisplaceAI/requirements.txt @@ -8,3 +8,5 @@ django-cors-headers==3.10.0 djangorestframework-simplejwt==4.6.0 channels==3.0.3 moviepy==1.0.3 +pytest==6.2.5 +pytest-django==4.4.0 \ No newline at end of file diff --git a/MisplaceAI/rules/__pycache__/models.cpython-310.pyc b/MisplaceAI/rules/__pycache__/models.cpython-310.pyc index 8566a281c578922a81b247f6b54ad2de86c68f7e..0fd537f915b71b779657e8588365fccf7c0ec8d7 100644 Binary files a/MisplaceAI/rules/__pycache__/models.cpython-310.pyc and b/MisplaceAI/rules/__pycache__/models.cpython-310.pyc differ diff --git a/MisplaceAI/rules/__pycache__/urls.cpython-310.pyc b/MisplaceAI/rules/__pycache__/urls.cpython-310.pyc index d1e3166ef871a541d7c32752c4f3046c7b5a0f10..574d44ef42f2b32d9988a259e80738126f1e99fc 100644 Binary files a/MisplaceAI/rules/__pycache__/urls.cpython-310.pyc and b/MisplaceAI/rules/__pycache__/urls.cpython-310.pyc differ diff --git a/MisplaceAI/rules/__pycache__/views.cpython-310.pyc b/MisplaceAI/rules/__pycache__/views.cpython-310.pyc index 91e3d6df835d284d3701c831bf2741222f17167a..640e602c37df9e18fdb78e344c73f3e2edbd9abe 100644 Binary files a/MisplaceAI/rules/__pycache__/views.cpython-310.pyc and b/MisplaceAI/rules/__pycache__/views.cpython-310.pyc differ diff --git a/MisplaceAI/rules/tests/test_views.py b/MisplaceAI/rules/tests/test_views.py new file mode 100644 index 0000000000000000000000000000000000000000..441e11b0f123ddec2554ec7c4ffacd233a72602e --- /dev/null +++ b/MisplaceAI/rules/tests/test_views.py @@ -0,0 +1,28 @@ +# misplaceAI/rules/tests/test_views.py + +from rest_framework.test import APITestCase +from rest_framework import status +from django.urls import reverse +from django.contrib.auth.models import User +from rules.models import Item + +class AdminManageItemViewTest(APITestCase): + + def setUp(self): + # Create a user + self.user = User.objects.create_user(username='testuser', password='testpassword') + self.client.force_authenticate(user=self.user) + + def test_create_item(self): + """ + Ensure we can create a new item. + """ + url = reverse('rules:admin_manage_item') + data = {'name': 'New Item'} + response = self.client.post(url, data, format='json') + + # Check if the response status is 201 Created + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + # Check if the item was actually created + self.assertEqual(Item.objects.count(), 1) + self.assertEqual(Item.objects.get().name, 'New Item') diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8d26de60b5227aab4fc4cb1944217d9d7fac4378 --- /dev/null +++ b/README.md @@ -0,0 +1,189 @@ +# Identification of Misplaced Items + + + + + + +testing command :docker exec -it identification-of-misplaced-items-web-1 pytest + + + + +ngrok http 8080 + + + + +docker-compose down +docker-compose up -d + +docker-compose up --build +## DATABASE + +### Connect though terminal + +```bash +docker exec -it identification-of-misplaced-items-db-1 mysql -u root -p +``` +<br> +Then enter password + +```bash +Enter password: rootpassword +``` + +<br> +Select Database: +```bash +mysql> USE misplaceai; +``` + +### Drop all tables + +Disable foreign key checks: + +``bash +SET FOREIGN_KEY_CHECKS = 0; +``` + +Generate and execute the drop script: + +```bash +SET @tables = NULL; +SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables +FROM information_schema.tables +WHERE table_schema = (SELECT DATABASE()); + +SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables); +PREPARE stmt FROM @tables; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; + +``` + +Enable foreign key checks: + +```bash +SET FOREIGN_KEY_CHECKS = 1; + +``` + +Verify that all tables are dropped: + +```sql +SHOW TABLES; +``` + +exir + +```bash +mysql> EXIT; +Bye +``` + + +## +migrations +```bash +docker-compose exec web python manage.py makemigrations +docker-compose exec web python manage.py migrate +``` + +create superuser: + +``` bashhttps://wrb.uwe.ac.uk/Scientia/Portal/Login.aspx?ReturnUrl=%2fScientia%2fPortal%2fMain.aspx + +docker-compose exec web python manage.py createsuperuser +``` + + +## Getting started + +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.uwe.ac.uk/a2-imeri/identification-of-misplaced-items.git +git branch -M main +git push -uf origin main +``` + +## Integrate with your tools + +- [ ] [Set up project integrations](https://gitlab.uwe.ac.uk/a2-imeri/identification-of-misplaced-items/-/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. diff --git a/frontend/package-lock.json b/frontend/package-lock.json index d244df8830336d2fe0a6d81187359350c2aad44b..37d0c110514f1d9512c1e6b9a95f01759b2c1a5a 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -17,6 +17,7 @@ "react": "^18.0.0", "react-bootstrap": "^2.10.2", "react-dom": "^18.0.0", + "react-icons": "^5.2.1", "react-router-dom": "^6.23.1", "react-scripts": "5.0.0", "web-vitals": "^1.0.1" @@ -16209,6 +16210,15 @@ "integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==", "license": "MIT" }, + "node_modules/react-icons": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.2.1.tgz", + "integrity": "sha512-zdbW5GstTzXaVKvGSyTaBalt7HSfuK5ovrzlpyiWHAFXndXTdd/1hdDHI4xBM1Mn7YriT6aqESucFl9kEXzrdw==", + "license": "MIT", + "peerDependencies": { + "react": "*" + } + }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index 16a73943ae9a82518b45318ba0934a72ebd36e1f..675632aceb38ffdb8d117bfdfba1bf695d7e7cf5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,6 +12,7 @@ "react": "^18.0.0", "react-bootstrap": "^2.10.2", "react-dom": "^18.0.0", + "react-icons": "^5.2.1", "react-router-dom": "^6.23.1", "react-scripts": "5.0.0", "web-vitals": "^1.0.1" diff --git a/frontend/src/components/detection/image/ImageUploadForm.js b/frontend/src/components/detection/image/ImageUploadForm.js index 268b51f72ee720e4e65483e1d5a2de99267c3c5b..46b7fe377d50a347f85f968ad6ae555edf345972 100644 --- a/frontend/src/components/detection/image/ImageUploadForm.js +++ b/frontend/src/components/detection/image/ImageUploadForm.js @@ -3,8 +3,8 @@ import React from 'react'; import 'bootstrap/dist/css/bootstrap.min.css'; import '../../../styles/main.css'; import '../../../styles/buttons/uploadButton.css'; -import UploadButton from '../../common/buttons/UploadButton'; -import TakePhotoButton from '../../common/buttons/TakePhotoButton'; +import UploadButton from '../../Common/buttons/UploadButton'; +import TakePhotoButton from '../../Common/buttons/TakePhotoButton'; const ImageUploadForm = ({ handleFileChange, handleSubmit, handleCameraClick, handleGalleryClick, isLoading }) => {