From f05de4c8e515977e3cc1601f195b1e1bf16164a6 Mon Sep 17 00:00:00 2001 From: yoyoyojoe Date: Thu, 2 Feb 2023 16:04:59 -0800 Subject: [PATCH 1/5] Add Permission-type tables Squash all previous minor commits --- .github/ISSUE_TEMPLATE/emergent-request.md | 2 +- .gitignore | 2 ++ app/core/admin.py | 6 +++++ app/core/api/serializers.py | 16 +++++++++++++ app/core/api/urls.py | 2 ++ app/core/api/views.py | 16 +++++++++++++ app/core/migrations/0015_permissiontype.py | 27 ++++++++++++++++++++++ app/core/models.py | 15 ++++++++++++ app/core/tests/conftest.py | 13 +++++++++++ app/core/tests/test_api.py | 9 ++++++++ app/core/tests/test_models.py | 14 +++++++++++ 11 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 app/core/migrations/0015_permissiontype.py diff --git a/.github/ISSUE_TEMPLATE/emergent-request.md b/.github/ISSUE_TEMPLATE/emergent-request.md index 26e611c4..67b20b2d 100644 --- a/.github/ISSUE_TEMPLATE/emergent-request.md +++ b/.github/ISSUE_TEMPLATE/emergent-request.md @@ -14,7 +14,7 @@ assignees: '' ### Issue you discovered this emergent requirement in - # -### Date discovered +### Date discovered ### Did you have to do something temporarily diff --git a/.gitignore b/.gitignore index 61fd560c..95e80b65 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ __pycache__ erd.png *.pyc + +.vscode diff --git a/app/core/admin.py b/app/core/admin.py index 09c4772a..6d605d8a 100644 --- a/app/core/admin.py +++ b/app/core/admin.py @@ -9,6 +9,7 @@ from .models import FaqViewed from .models import Language from .models import Location +from .models import PermissionType from .models import PracticeArea from .models import ProgramArea from .models import Project @@ -209,3 +210,8 @@ class LanguageAdmin(admin.ModelAdmin): ) list_filter = ("name",) + + +@admin.register(PermissionType) +class PermissionTypeAdmin(admin.ModelAdmin): + list_display = ("name", "description") diff --git a/app/core/api/serializers.py b/app/core/api/serializers.py index 5b40ef31..922e56b7 100644 --- a/app/core/api/serializers.py +++ b/app/core/api/serializers.py @@ -5,6 +5,7 @@ from core.models import FaqViewed from core.models import Language from core.models import Location +from core.models import PermissionType from core.models import PracticeArea from core.models import ProgramArea from core.models import Project @@ -267,3 +268,18 @@ class Meta: "created_at", "updated_at", ) + + +class PermissionTypeSerializer(serializers.ModelSerializer): + """ + Used to retrieve each permission_type info + """ + + class Meta: + model = PermissionType + fields = ("uuid", "name", "description") + read_only_fields = ( + "uuid", + "created_at", + "updated_at", + ) diff --git a/app/core/api/urls.py b/app/core/api/urls.py index 46a32b7e..b387fca4 100644 --- a/app/core/api/urls.py +++ b/app/core/api/urls.py @@ -5,6 +5,7 @@ from .views import FaqViewSet from .views import LanguageViewSet from .views import LocationViewSet +from .views import PermissionTypeViewSet from .views import PracticeAreaViewSet from .views import ProgramAreaViewSet from .views import ProjectViewSet @@ -28,6 +29,7 @@ router.register(r"skills", SkillViewSet, basename="skill") router.register(r"technologies", TechnologyViewSet, basename="technology") router.register(r"languages", LanguageViewSet, basename="language") +router.register(r"permission-types", PermissionTypeViewSet, basename="permission-type") urlpatterns = [ path("me/", UserProfileAPIView.as_view(), name="my_profile"), diff --git a/app/core/api/views.py b/app/core/api/views.py index 29730ca1..126fd516 100644 --- a/app/core/api/views.py +++ b/app/core/api/views.py @@ -15,6 +15,7 @@ from ..models import FaqViewed from ..models import Language from ..models import Location +from ..models import PermissionType from ..models import PracticeArea from ..models import ProgramArea from ..models import Project @@ -26,6 +27,7 @@ from .serializers import FaqViewedSerializer from .serializers import LanguageSerializer from .serializers import LocationSerializer +from .serializers import PermissionTypeSerializer from .serializers import PracticeAreaSerializer from .serializers import ProgramAreaSerializer from .serializers import ProjectSerializer @@ -282,3 +284,17 @@ class LanguageViewSet(viewsets.ModelViewSet): permission_classes = [IsAuthenticated] queryset = Language.objects.all() serializer_class = LanguageSerializer + + +@extend_schema_view( + list=extend_schema(description="Return a list of all permission types"), + create=extend_schema(description="Create a new permission type"), + retrieve=extend_schema(description="Return the details of a permission type"), + destroy=extend_schema(description="Delete a permission type"), + update=extend_schema(description="Update a permission type"), + partial_update=extend_schema(description="Patch a permission type"), +) +class PermissionTypeViewSet(viewsets.ModelViewSet): + permission_classes = [IsAuthenticated] + queryset = PermissionType.objects.all() + serializer_class = PermissionTypeSerializer diff --git a/app/core/migrations/0015_permissiontype.py b/app/core/migrations/0015_permissiontype.py new file mode 100644 index 00000000..17372bb0 --- /dev/null +++ b/app/core/migrations/0015_permissiontype.py @@ -0,0 +1,27 @@ +# Generated by Django 4.0.10 on 2023-09-21 05:48 + +from django.db import migrations, models +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0014_language'), + ] + + operations = [ + migrations.CreateModel( + name='PermissionType', + fields=[ + ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)), + ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created at')), + ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated at')), + ('name', models.CharField(max_length=255)), + ('description', models.TextField(blank=True)), + ], + options={ + 'abstract': False, + }, + ), + ] diff --git a/app/core/models.py b/app/core/models.py index 65cd1cbf..1f8f3688 100644 --- a/app/core/models.py +++ b/app/core/models.py @@ -305,3 +305,18 @@ class Language(AbstractBaseModel): def __str__(self): return f"{self.name}" + + +class PermissionType(AbstractBaseModel): + """ + Permission Type + """ + + name = models.CharField(max_length=255) + description = models.TextField(blank=True) + + def __str__(self): + if self.description and isinstance(self.description, str): + return f"{self.name}: {self.description}" + else: + return f"{self.name}" diff --git a/app/core/tests/conftest.py b/app/core/tests/conftest.py index f85e1f92..8a858157 100644 --- a/app/core/tests/conftest.py +++ b/app/core/tests/conftest.py @@ -5,6 +5,7 @@ from ..models import FaqViewed from ..models import Language from ..models import Location +from ..models import PermissionType from ..models import PracticeArea from ..models import ProgramArea from ..models import Project @@ -122,3 +123,15 @@ def technology(): @pytest.fixture def language(): return Language.objects.create(name="Test Language") + + +@pytest.fixture +def permission_type1(): + return PermissionType.objects.create(name="Test Permission Type", description="") + + +@pytest.fixture +def permission_type2(): + return PermissionType.objects.create( + name="Test Permission Type", description="A permission type description" + ) diff --git a/app/core/tests/test_api.py b/app/core/tests/test_api.py index 5d3bdb2a..44f30353 100644 --- a/app/core/tests/test_api.py +++ b/app/core/tests/test_api.py @@ -18,6 +18,7 @@ SKILL_URL = reverse("skill-list") TECHNOLOGY_URL = reverse("technology-list") LANGUAGES_URL = reverse("language-list") +PERMISSION_TYPE = reverse("permission-type-list") CREATE_USER_PAYLOAD = { "username": "TestUserAPI", @@ -274,3 +275,11 @@ def test_create_language(auth_client): # add project_language_xref to params res = auth_client.post(LANGUAGES_URL, payload) assert res.status_code == status.HTTP_201_CREATED assert res.data["name"] == payload["name"] + + +def test_create_permission_type(auth_client): + payload = {"name": "adminGlobal", "description": "Can CRUD anything"} + res = auth_client.post(PERMISSION_TYPE, payload) + assert res.status_code == status.HTTP_201_CREATED + assert res.data["name"] == payload["name"] + assert res.data["description"] == payload["description"] diff --git a/app/core/tests/test_models.py b/app/core/tests/test_models.py index a9f79267..87fe1ab4 100644 --- a/app/core/tests/test_models.py +++ b/app/core/tests/test_models.py @@ -48,3 +48,17 @@ def test_technology(technology): def test_language(language): assert str(language) == "Test Language" + + +def test_permission_type1(permission_type1): + assert str(permission_type1.name) == "Test Permission Type" + assert str(permission_type1.description) == "" + assert str(permission_type1) == "Test Permission Type" + + +def test_permission_type2(permission_type2): + assert str(permission_type2.name) == "Test Permission Type" + assert str(permission_type2.description) == "A permission type description" + assert ( + str(permission_type2) == "Test Permission Type: A permission type description" + ) From 659f49a1f03f0f7897abca755f3c6aeb7d407dbe Mon Sep 17 00:00:00 2001 From: Ben_P Date: Thu, 28 Sep 2023 01:31:55 +0300 Subject: [PATCH 2/5] Update existing Django model by deleting URL fileds --- app/core/api/serializers.py | 6 --- ...ove_project_github_primary_url_and_more.py | 37 +++++++++++++++++++ app/core/models.py | 6 --- 3 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 app/core/migrations/0016_remove_project_github_primary_url_and_more.py diff --git a/app/core/api/serializers.py b/app/core/api/serializers.py index 922e56b7..00371452 100644 --- a/app/core/api/serializers.py +++ b/app/core/api/serializers.py @@ -86,17 +86,11 @@ class Meta: "completed_at", "github_org_id", "github_primary_repo_id", - "github_primary_url", "hide", - "slack_url", - "google_drive_url", "google_drive_id", - "hfla_website_url", "image_logo", "image_hero", "image_icon", - "readme_url", - "wiki_url", ) read_only_fields = ( "uuid", diff --git a/app/core/migrations/0016_remove_project_github_primary_url_and_more.py b/app/core/migrations/0016_remove_project_github_primary_url_and_more.py new file mode 100644 index 00000000..3f040148 --- /dev/null +++ b/app/core/migrations/0016_remove_project_github_primary_url_and_more.py @@ -0,0 +1,37 @@ +# Generated by Django 4.0.10 on 2023-09-27 22:12 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0015_permissiontype'), + ] + + operations = [ + migrations.RemoveField( + model_name='project', + name='github_primary_url', + ), + migrations.RemoveField( + model_name='project', + name='google_drive_url', + ), + migrations.RemoveField( + model_name='project', + name='hfla_website_url', + ), + migrations.RemoveField( + model_name='project', + name='readme_url', + ), + migrations.RemoveField( + model_name='project', + name='slack_url', + ), + migrations.RemoveField( + model_name='project', + name='wiki_url', + ), + ] diff --git a/app/core/models.py b/app/core/models.py index 1f8f3688..e1442b57 100644 --- a/app/core/models.py +++ b/app/core/models.py @@ -131,21 +131,15 @@ class Project(AbstractBaseModel): "Authorization: token [gh_PAT]" \ https://api.github.com/repos/[org]/[repo]', ) - github_primary_url = models.CharField(max_length=255, blank=True) # current_status_id = models.ForeignKey("status", on_delete=models.PROTECT) hide = models.BooleanField(default=True) # location_id = models.ForeignKey("location", on_delete=models.PROTECT) - slack_url = models.URLField(blank=True) - google_drive_url = models.URLField(blank=True) google_drive_id = models.CharField(max_length=255, blank=True) - hfla_website_url = models.URLField(blank=True) # leads = models.ManyToManyField("lead") # leadership_type_id = models.ForeignKey("leadership_type", on_delete=models.PROTECT) image_logo = models.URLField(blank=True) image_hero = models.URLField(blank=True) image_icon = models.URLField(blank=True) - readme_url = models.URLField(blank=True) - wiki_url = models.URLField(blank=True) def __str__(self): return f"{self.name}" From b8d7382ea57b3adaee9c7d012101f8b27f2b60ca Mon Sep 17 00:00:00 2001 From: AzaniaBG Date: Tue, 3 Oct 2023 12:24:01 -0700 Subject: [PATCH 3/5] removed language table models and tests --- app/core/admin.py | 12 ------------ app/core/api/serializers.py | 21 --------------------- app/core/api/urls.py | 2 -- app/core/api/views.py | 16 ---------------- app/core/migrations/0017_delete_language.py | 16 ++++++++++++++++ app/core/models.py | 15 --------------- app/core/tests/conftest.py | 8 -------- app/core/tests/test_api.py | 14 -------------- app/core/tests/test_models.py | 4 ---- 9 files changed, 16 insertions(+), 92 deletions(-) create mode 100644 app/core/migrations/0017_delete_language.py diff --git a/app/core/admin.py b/app/core/admin.py index 6d605d8a..7f98c2fd 100644 --- a/app/core/admin.py +++ b/app/core/admin.py @@ -7,7 +7,6 @@ from .models import Faq from .models import FaqViewed -from .models import Language from .models import Location from .models import PermissionType from .models import PracticeArea @@ -201,17 +200,6 @@ class TechnologyAdmin(admin.ModelAdmin): ) -@admin.register(Language) -class LanguageAdmin(admin.ModelAdmin): - list_display = ( - "name", - "description", - "logo", - ) - - list_filter = ("name",) - - @admin.register(PermissionType) class PermissionTypeAdmin(admin.ModelAdmin): list_display = ("name", "description") diff --git a/app/core/api/serializers.py b/app/core/api/serializers.py index 00371452..69ddb362 100644 --- a/app/core/api/serializers.py +++ b/app/core/api/serializers.py @@ -3,7 +3,6 @@ from core.models import Faq from core.models import FaqViewed -from core.models import Language from core.models import Location from core.models import PermissionType from core.models import PracticeArea @@ -244,26 +243,6 @@ class Meta: ) -class LanguageSerializer(serializers.ModelSerializer): - """ - Used to retrieve Language info - """ - - class Meta: - model = Language - fields = ( - "uuid", - "name", - "description", - "logo", - ) - read_only_fields = ( - "uuid", - "created_at", - "updated_at", - ) - - class PermissionTypeSerializer(serializers.ModelSerializer): """ Used to retrieve each permission_type info diff --git a/app/core/api/urls.py b/app/core/api/urls.py index b387fca4..247919b6 100644 --- a/app/core/api/urls.py +++ b/app/core/api/urls.py @@ -3,7 +3,6 @@ from .views import FaqViewedViewSet from .views import FaqViewSet -from .views import LanguageViewSet from .views import LocationViewSet from .views import PermissionTypeViewSet from .views import PracticeAreaViewSet @@ -28,7 +27,6 @@ router.register(r"program-areas", ProgramAreaViewSet, basename="program-area") router.register(r"skills", SkillViewSet, basename="skill") router.register(r"technologies", TechnologyViewSet, basename="technology") -router.register(r"languages", LanguageViewSet, basename="language") router.register(r"permission-types", PermissionTypeViewSet, basename="permission-type") urlpatterns = [ diff --git a/app/core/api/views.py b/app/core/api/views.py index 126fd516..8f99a5a9 100644 --- a/app/core/api/views.py +++ b/app/core/api/views.py @@ -13,7 +13,6 @@ from ..models import Faq from ..models import FaqViewed -from ..models import Language from ..models import Location from ..models import PermissionType from ..models import PracticeArea @@ -25,7 +24,6 @@ from ..models import Technology from .serializers import FaqSerializer from .serializers import FaqViewedSerializer -from .serializers import LanguageSerializer from .serializers import LocationSerializer from .serializers import PermissionTypeSerializer from .serializers import PracticeAreaSerializer @@ -272,20 +270,6 @@ class TechnologyViewSet(viewsets.ModelViewSet): serializer_class = TechnologySerializer -@extend_schema_view( - list=extend_schema(description="Return a list of all languages"), - create=extend_schema(description="Create a new language"), - retrieve=extend_schema(description="Return the details of a language"), - destroy=extend_schema(description="Delete a language"), - update=extend_schema(description="Update a language"), - partial_update=extend_schema(description="Patch a language"), -) -class LanguageViewSet(viewsets.ModelViewSet): - permission_classes = [IsAuthenticated] - queryset = Language.objects.all() - serializer_class = LanguageSerializer - - @extend_schema_view( list=extend_schema(description="Return a list of all permission types"), create=extend_schema(description="Create a new permission type"), diff --git a/app/core/migrations/0017_delete_language.py b/app/core/migrations/0017_delete_language.py new file mode 100644 index 00000000..e503c23a --- /dev/null +++ b/app/core/migrations/0017_delete_language.py @@ -0,0 +1,16 @@ +# Generated by Django 4.0.10 on 2023-10-16 22:42 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0016_remove_project_github_primary_url_and_more'), + ] + + operations = [ + migrations.DeleteModel( + name='Language', + ), + ] diff --git a/app/core/models.py b/app/core/models.py index e1442b57..552ec2fb 100644 --- a/app/core/models.py +++ b/app/core/models.py @@ -286,21 +286,6 @@ def __str__(self): return f"{self.name}" -class Language(AbstractBaseModel): - """ - Language table to update a shared data store(associated with project_language_xref) - """ - - name = models.CharField(max_length=255) - description = models.TextField(blank=True) - logo = models.URLField(blank=True) - # project_language_xref = models.ForeignKey(Project_Language_Xref, on_delete=models.CASCADE) - # ^^^ uncomment once created - - def __str__(self): - return f"{self.name}" - - class PermissionType(AbstractBaseModel): """ Permission Type diff --git a/app/core/tests/conftest.py b/app/core/tests/conftest.py index 8a858157..cbd27fd7 100644 --- a/app/core/tests/conftest.py +++ b/app/core/tests/conftest.py @@ -3,7 +3,6 @@ from ..models import Faq from ..models import FaqViewed -from ..models import Language from ..models import Location from ..models import PermissionType from ..models import PracticeArea @@ -14,8 +13,6 @@ from ..models import SponsorPartner from ..models import Technology -# from ..models import Project_Language_Xref # uncomment once created - @pytest.fixture def user(django_user_model): @@ -120,11 +117,6 @@ def technology(): return Technology.objects.create(name="Test Technology") -@pytest.fixture -def language(): - return Language.objects.create(name="Test Language") - - @pytest.fixture def permission_type1(): return PermissionType.objects.create(name="Test Permission Type", description="") diff --git a/app/core/tests/test_api.py b/app/core/tests/test_api.py index 44f30353..3e7f69f2 100644 --- a/app/core/tests/test_api.py +++ b/app/core/tests/test_api.py @@ -17,7 +17,6 @@ PROGRAM_AREA_URL = reverse("program-area-list") SKILL_URL = reverse("skill-list") TECHNOLOGY_URL = reverse("technology-list") -LANGUAGES_URL = reverse("language-list") PERMISSION_TYPE = reverse("permission-type-list") CREATE_USER_PAYLOAD = { @@ -264,19 +263,6 @@ def test_create_technology(auth_client): assert res.data["name"] == payload["name"] -def test_create_language(auth_client): # add project_language_xref to params - """Test to create a language""" - - payload = { - "name": "Test Language", - "description": "Test Language Description", - # "project language": project_language_xref.uuid - } - res = auth_client.post(LANGUAGES_URL, payload) - assert res.status_code == status.HTTP_201_CREATED - assert res.data["name"] == payload["name"] - - def test_create_permission_type(auth_client): payload = {"name": "adminGlobal", "description": "Can CRUD anything"} res = auth_client.post(PERMISSION_TYPE, payload) diff --git a/app/core/tests/test_models.py b/app/core/tests/test_models.py index 87fe1ab4..9bd4a857 100644 --- a/app/core/tests/test_models.py +++ b/app/core/tests/test_models.py @@ -46,10 +46,6 @@ def test_technology(technology): assert str(technology) == "Test Technology" -def test_language(language): - assert str(language) == "Test Language" - - def test_permission_type1(permission_type1): assert str(permission_type1.name) == "Test Permission Type" assert str(permission_type1.description) == "" From fede998289b9ee8c5440482635a8f1f572e3b8f2 Mon Sep 17 00:00:00 2001 From: Ben_P Date: Thu, 5 Oct 2023 19:17:01 +0300 Subject: [PATCH 4/5] Updated CONTRIBUTING.md file --- docs/CONTRIBUTING.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index d487fa74..4a447f1d 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -34,7 +34,14 @@ Set up two-factor authentication on your account by following this [guide](https Before cloning your forked repository to your local machine, you must have Git installed. You can find instructions for installing Git for your operating system [**here**](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). -For Windows, you may want to [install a Windows Subsystem for Linux (WSL)](https://code.visualstudio.com/docs/remote/wsl) and then install Git from WSL. +Installation Guide for Windows Users +- we recommend [installing Windows Subsystem for Linux (WSL)](https://code.visualstudio.com/docs/remote/wsl). WSL provides a Linux-compatible environment that can prevent common errors during script execution. +- After setting up WSL, install Git directly from the Linux terminal. This method can help avoid complications that sometimes arise when using Git Bash on Windows. +- If you prefer Git Bash or encounter errors related to line endings when running scripts, the problem might be due to file conversions in Windows. To address this, configure Git as follows: +```bash + git config --system set autocrlf=false +``` +Feel free to reach out in the [Hack for LA Slack channel](https://hackforla.slack.com/messages/people-depot/) if you encounter any errors while running scripts on Windows. Please note that if you have a Mac the page offers several options (see other option, if you need to conserve hard drive space) including: From e841466d05ae2f7c82378851edad3f2bb0467b57 Mon Sep 17 00:00:00 2001 From: Bonnie Wolfe <37763229+ExperimentsInHonesty@users.noreply.github.com> Date: Thu, 5 Oct 2023 17:34:36 -0700 Subject: [PATCH 5/5] Create pull_request_template.md Add pr template from website team to this repo --- .github/pull_request_template.md | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..070b6ca8 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,33 @@ +Fixes #replace_this_text_with_the_issue_number + +### What changes did you make? + +- +- +- + +### Why did you make the changes (we will use this info to test)? + +- +- +- + +### Screenshots of Proposed Changes Of The Website (if any, please do not screen shot code changes) + + + + + +
+Visuals before changes are applied + +![image](Paste_Your_Image_Link_Here_After_Attaching_Files) + +
+ +
+Visuals after changes are applied + +![image](Paste_Your_Image_Link_Here_After_Attaching_Files) + +