Skip to content

Commit

Permalink
Misc docstring and comment changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed May 4, 2024
1 parent 9218de3 commit a39c5fe
Show file tree
Hide file tree
Showing 20 changed files with 75 additions and 90 deletions.
15 changes: 10 additions & 5 deletions backend/authentication/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@


class UserCreationForm(forms.ModelForm[UserModel]):
"""A form for creating new users. Includes all the required
fields, plus a repeated password."""
"""
A form for creating new users.
Includes all the required fields, plus a repeated password.
"""

password1 = forms.CharField(label="Password", widget=forms.PasswordInput)
password2 = forms.CharField(
Expand Down Expand Up @@ -48,9 +51,11 @@ def save(self, commit: bool = True) -> UserModel:


class UserChangeForm(forms.ModelForm[UserModel]):
"""A form for updating users. Includes all the fields on
the user, but replaces the password field with admin's
disabled password hash display field.
"""
A form for updating users.
Includes all the fields on the user.
Replaces the password field with admin's disabled password hash display field.
"""

password = ReadOnlyPasswordHashField()
Expand Down
12 changes: 1 addition & 11 deletions backend/authentication/models.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
"""
Authentication Models
This file contains models for the authentication app.
Contents:
- SupportEntityType
- Support
- UserModel
- UserResource
- UserTask
- UserTopic
Models for the authentication app.
"""

from typing import Any
Expand Down
4 changes: 4 additions & 0 deletions backend/authentication/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Serializers for the authentication app.
"""

import re
from typing import Any, Dict, Union

Expand Down
4 changes: 4 additions & 0 deletions backend/authentication/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Testing for the authentication app.
"""

import pytest
from .factories import (
SupportEntityTypeFactory,
Expand Down
13 changes: 8 additions & 5 deletions backend/backend/mixins/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

class IdMixin(models.Model):
"""
Mixin for models with incrementing Integer primary key
------------------------------------------------------
Mixin for models with incrementing Integer primary key.
This mixin is used for models that have an incrementing Integer primary key.
Default in django is an incrementing Integer primary key. Creating this explicity helps with code highlighting.
Default in Django is an incrementing Integer primary key. Creating this explicitly helps with code highlighting.
"""

id = models.AutoField(primary_key=True)
Expand All @@ -20,7 +19,9 @@ class Meta:


class UUIDModelMixin(models.Model):
"""Mixin for models with UUID primary key"""
"""
Mixin for models with UUID primary key.
"""

id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)

Expand All @@ -29,7 +30,9 @@ class Meta:


class CreationDeletionMixin(models.Model):
"""Mixin for model with creation and deletion date"""
"""
Mixin for model with creation and deletion date.
"""

creation_date = models.DateTimeField(_("Created at"), auto_now_add=True)
deletion_date = models.DateTimeField(_("Deletion date"), null=True, blank=True)
Expand Down
4 changes: 2 additions & 2 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Django settings for activist.org.
For more information on this file, see
For more information on this file, see:
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
For the full list of settings and their values, see:
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

Expand Down
18 changes: 1 addition & 17 deletions backend/content/models.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
"""
Content Models
This file contains models for the content app.
Contents:
- Discussion
- DiscussionEntry
- Faq
- Resource
- Task
- Topic
- Tag
- ResourceTopic
- ResourceTag
- TopicFormat
- DiscussionTag
- Image
Models for the content app.
"""

from uuid import uuid4
Expand Down
4 changes: 4 additions & 0 deletions backend/content/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Serializers for the content app.
"""

from typing import Dict, Union

from django.utils.translation import gettext as _
Expand Down
4 changes: 4 additions & 0 deletions backend/content/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Testing for the content app.
"""

from .factories import ResourceFactory, TaskFactory, TopicFactory, ResourceTopicFactory
from tests.throttle import BaseTestThrottle
from django.urls import reverse
Expand Down
7 changes: 4 additions & 3 deletions backend/content/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def list(self, request: Request) -> Response:
return self.get_paginated_response(self.paginate_queryset(serializer.data))

def update(self, request: Request, pk: str | None = None) -> Response:
"""Just the created_by user can update the discussion"""
"""
Just the created_by user can update the discussion.
"""
item = self.get_object()
if item.created_by != request.user:
return Response(
Expand All @@ -100,8 +102,7 @@ def partial_update(self, request: Request, pk: str | None = None) -> Response:

def destroy(self, request: Request, pk: str | None = None) -> Response:
"""
Deleted the whole discussion
- Only the created_by user can delete it
Deleted the whole discussion - requires created_by user.
"""
item = self.get_object()
if item.created_by != request.user:
Expand Down
20 changes: 1 addition & 19 deletions backend/entities/models.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
"""
Entities Models
This file contains models for the entities app.
Contents:
- Organization
- OrganizationApplication
- OrganizationEvent
- OrganizationImage
- OrganizationMember
- OrganizationResource
- Group
- OrganizationTask
- OrganizationTopic
- GroupEvent
- GroupImage
- GroupMember
- GroupResource
- GroupTopic
Models for the entities app.
"""

from uuid import uuid4
Expand Down
4 changes: 4 additions & 0 deletions backend/entities/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Serializers for the entities app.
"""

from rest_framework import serializers

from .models import (
Expand Down
4 changes: 4 additions & 0 deletions backend/entities/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Testing for the entities app.
"""

from django.urls import reverse
from tests.throttle import BaseTestThrottle

Expand Down
17 changes: 1 addition & 16 deletions backend/events/models.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
"""
Events Models
This file contains models for the events app.
Contents:
- Event
- Format
- Role
- EventAttendee
- EventFormat
- EventAttendeeStatus
- EventResource
- EventRole
- EventTask
- EventTopic
- EventTag
Models for the events app.
"""

from uuid import uuid4
Expand Down
4 changes: 4 additions & 0 deletions backend/events/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Serializers for the events app.
"""

from typing import Dict, Union

from django.utils.dateparse import parse_datetime
Expand Down
4 changes: 4 additions & 0 deletions backend/events/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Testing for the events app.
"""

from django.urls import reverse
from tests.throttle import BaseTestThrottle

Expand Down
8 changes: 6 additions & 2 deletions backend/manage.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
"""
Django's command-line utility for administrative tasks.
"""

import os
import sys


def main() -> None:
"""Run administrative tasks."""
"""
Run administrative tasks.
"""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings")
try:
from django.core.management import execute_from_command_line
Expand Down
1 change: 0 additions & 1 deletion backend/tests/throttle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
class BaseTestThrottle:
"""
Base class for testing throttling.
----------------------------------
This is a base class for testing throttling.
Expand Down
14 changes: 7 additions & 7 deletions frontend/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ const environments = {
prod: "https://activist.org",
};

// Determine the environment from the command line or default to 'local'
// Determine the environment from the command line or default to 'local'.
const ENV = (process.env.TEST_ENV || "local") as keyof typeof environments;

export default defineConfig({
testDir: "./tests/specs",
/* Run tests in files in parallel */
/* Run tests in files in parallel. */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
/* Retry on CI only. */
retries: process.env.CI ? 4 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
/* Reporter to use. See https://playwright.dev/docs/test-reporters. */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: environments[ENV],

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer. */
trace: "on-first-retry",
},

/* Configure projects for major desktop browsers */
/* Configure projects for major desktop browsers. */
projects: [
{
name: "chromium",
Expand Down Expand Up @@ -88,7 +88,7 @@ export default defineConfig({
// },
],

/* Run your local dev server before starting the tests */
/* Run your local dev server before starting the tests. */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
Expand Down
4 changes: 2 additions & 2 deletions frontend/tests/specs/landing-page.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test, LandingPage } from "../fixtures/page-fixtures";
import AxeBuilder from "@axe-core/playwright";
import { LandingPage, expect, test } from "../fixtures/page-fixtures";

test.describe("Landing Page", () => {
// Initialize page before each test, wait for the landing splash to be visible.
Expand All @@ -9,7 +9,7 @@ test.describe("Landing Page", () => {
await landingSplash.waitFor({ state: "visible" });
});

// Test accessibility of the landing page (skip this test for now)
// Test accessibility of the landing page (skip this test for now).
test.skip("should not have any detectable accessibility issues", async ({
landingPage,
}, testInfo) => {
Expand Down

0 comments on commit a39c5fe

Please sign in to comment.