Skip to content

Commit

Permalink
fixed stack_element_type test and auto formatted contributing.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AzaniaBG committed Oct 22, 2023
2 parents 7415ee0 + e841466 commit 88efd5e
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 16 deletions.
33 changes: 33 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -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)

<!-- Note, if your images are too big, use the <img src="" width="" length="" /> syntax instead of ![image](link) to format the images -->

<!-- If images are not loading properly, you might need to double check the syntax or add a newline after the closing </summary> tag -->

<details>
<summary>Visuals before changes are applied</summary>

![image](Paste_Your_Image_Link_Here_After_Attaching_Files)

</details>

<details>
<summary>Visuals after changes are applied</summary>

![image](Paste_Your_Image_Link_Here_After_Attaching_Files)

</details>
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ __pycache__
erd.png

*.pyc

.vscode
6 changes: 6 additions & 0 deletions app/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .models import Faq
from .models import FaqViewed
from .models import Location
from .models import PermissionType
from .models import PracticeArea
from .models import ProgramArea
from .models import Project
Expand Down Expand Up @@ -200,6 +201,11 @@ class TechnologyAdmin(admin.ModelAdmin):
)


@admin.register(PermissionType)
class PermissionTypeAdmin(admin.ModelAdmin):
list_display = ("name", "description")


@admin.register(StackElementType)
class StackElementType(admin.ModelAdmin):
list_display = (
Expand Down
23 changes: 17 additions & 6 deletions app/core/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from core.models import Faq
from core.models import FaqViewed
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
Expand Down Expand Up @@ -85,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",
Expand Down Expand Up @@ -249,6 +244,22 @@ class Meta:
)


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",
)
read_only_fields = ("uuid",)


class StackElementTypeSerializer(serializers.ModelSerializer):
"""Used to retrieve stack element types"""

Expand Down
2 changes: 2 additions & 0 deletions app/core/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .views import FaqViewedViewSet
from .views import FaqViewSet
from .views import LocationViewSet
from .views import PermissionTypeViewSet
from .views import PracticeAreaViewSet
from .views import ProgramAreaViewSet
from .views import ProjectViewSet
Expand All @@ -30,6 +31,7 @@
router.register(
r"stack-element-types", StackElementTypeViewSet, basename="stack-element-type"
)
router.register(r"permission-types", PermissionTypeViewSet, basename="permission-type")

urlpatterns = [
path("me/", UserProfileAPIView.as_view(), name="my_profile"),
Expand Down
16 changes: 16 additions & 0 deletions app/core/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from ..models import Faq
from ..models import FaqViewed
from ..models import Location
from ..models import PermissionType
from ..models import PracticeArea
from ..models import ProgramArea
from ..models import Project
Expand All @@ -25,6 +26,7 @@
from .serializers import FaqSerializer
from .serializers import FaqViewedSerializer
from .serializers import LocationSerializer
from .serializers import PermissionTypeSerializer
from .serializers import PracticeAreaSerializer
from .serializers import ProgramAreaSerializer
from .serializers import ProjectSerializer
Expand Down Expand Up @@ -270,6 +272,20 @@ class TechnologyViewSet(viewsets.ModelViewSet):
serializer_class = TechnologySerializer


@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


@extend_schema_view(
list=extend_schema(description="Return a list of all the stack element types"),
create=extend_schema(description="Create a new stack element type"),
Expand Down
27 changes: 27 additions & 0 deletions app/core/migrations/0015_permissiontype.py
Original file line number Diff line number Diff line change
@@ -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_stackelementtype'),
]

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,
},
),
]
Original file line number Diff line number Diff line change
@@ -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',
),
]
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Generated by Django 4.0.10 on 2023-10-17 13:22
# Generated by Django 4.0.10 on 2023-10-22 16:07

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0014_stackelementtype'),
('core', '0016_remove_project_github_primary_url_and_more'),
]

operations = [
Expand Down
26 changes: 19 additions & 7 deletions app/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -292,6 +286,21 @@ 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}"


class StackElementType(AbstractBaseModel):
"""
Stack element type used to update a shared data store across projects
Expand All @@ -306,4 +315,7 @@ class Meta:
verbose_name_plural = "Stack Element Types"

def __str__(self):
return f"{self.name}"
if self.description and isinstance(self.description, str):
return f"{self.name}: {self.description}"
else:
return f"{self.name}"
13 changes: 13 additions & 0 deletions app/core/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ..models import Faq
from ..models import FaqViewed
from ..models import Location
from ..models import PermissionType
from ..models import PracticeArea
from ..models import ProgramArea
from ..models import Project
Expand Down Expand Up @@ -117,6 +118,18 @@ def technology():
return Technology.objects.create(name="Test Technology")


@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"
)


@pytest.fixture
def stack_element_type():
return StackElementType.objects.create(name="Test Stack Element Type")
10 changes: 10 additions & 0 deletions app/core/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SKILL_URL = reverse("skill-list")
TECHNOLOGY_URL = reverse("technology-list")
STACK_ELEMENT_TYPE_URL = reverse("stack-element-type-list")
PERMISSION_TYPE = reverse("permission-type-list")

CREATE_USER_PAYLOAD = {
"username": "TestUserAPI",
Expand Down Expand Up @@ -271,3 +272,12 @@ def test_create_stack_element_type(auth_client):
res = auth_client.post(STACK_ELEMENT_TYPE_URL, payload)
assert res.status_code == status.HTTP_201_CREATED
assert res.data["name"] == payload["name"]
assert res.data["description"] == payload["description"]


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"]
14 changes: 14 additions & 0 deletions app/core/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,19 @@ def test_technology(technology):
assert str(technology) == "Test Technology"


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"
)


def test_stack_element_type(stack_element_type):
assert str(stack_element_type) == "Test Stack Element Type"
9 changes: 8 additions & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
<strong><em>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. </em></strong>

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:

Expand Down

0 comments on commit 88efd5e

Please sign in to comment.