Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Username aliases #588

Merged
merged 26 commits into from
Sep 19, 2024
Merged

Username aliases #588

merged 26 commits into from
Sep 19, 2024

Conversation

brassy-endomorph
Copy link
Collaborator

@brassy-endomorph brassy-endomorph commented Sep 14, 2024

This is a draft PR that does the following:

  • removes prettier for jinja because it keeps fucking up the jinja templates so that they produce incorrect HTML
  • adds a super basic dev_data.py shell to populate the DB
  • initializes the DB via db.create_all() (not Alembic) so that local DB changes appear for improved dev experience
  • refactors to split logic into smaller more self-contained files
  • creates a Username type that holds all the bio/fields for primary/secondary users and also is the target for messages

TODOs:

  • Alembic migrations
  • Tests
  • Toggle verification status of aliases

Closes #498

dev_data.py Fixed Show fixed Hide fixed
@jeremywmoore
Copy link
Collaborator

Instead of removing prettier entirely, can we just disable it for the templates directory?

hushline/make_admin.py Outdated Show resolved Hide resolved
hushline/routes.py Outdated Show resolved Hide resolved
Copy link
Member

@glenn-sorrentino glenn-sorrentino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! I'll open a CSS PR shortly, but here are a few notes:

Steps & Feedback:

  1. ✅ Added a new alias
  2. ✅ Update display name
    • When I update an alias Display Name the field clears after saving, and it's not immediately understood if it did in fact save.
      • The new value should be visible in the input.
    • When a Display Name is added, the page heading should show the new display name.
      • Before: Alias:@hr-dept
      • After (with Display Name): Alias: HR Department
    • Current Aliases list should show only the updated Display Name after saving
  3. ✅ Added alias to directory
  4. Added bio and links to alias
    • ✅ Bio visible in directory listing
    • ⛔️ Bio not visible on profile page
    • ⛔️ Links not visible on alias profile page
  5. ✅ Added primary user to directory
  6. Added bio and links to primary username
    • ✅ Bio visible in directory listing
    • ✅ Bio AND links visible on profile page
    • ⛔️ Bio of primary username is displayed for the alias

@brassy-endomorph
Copy link
Collaborator Author

Just noting that two of the three bugs happened because of Jinja's sloppy handling of AttributeErrors and undefined which would be solved by #577

dev_data.py Fixed Show fixed Hide fixed
@brassy-endomorph brassy-endomorph force-pushed the username-aliases branch 2 times, most recently from dd6a833 to a5cb55d Compare September 17, 2024 20:09
@brassy-endomorph brassy-endomorph marked this pull request as ready for review September 17, 2024 20:16
Copy link

github-actions bot commented Sep 18, 2024

Terraform plan in terraform/dev in the hushline-dev-username-aliases workspace

With variables

branch = "username-aliases"
name   = "dev-username-aliases"
Plan: 3 to add, 0 to change, 0 to destroy. Changes to Outputs.
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+   create

Terraform will perform the following actions:

  # digitalocean_project.hush_line_dev will be created
+   resource "digitalocean_project" "hush_line_dev" {
+       created_at  = (known after apply)
+       description = "Development instance based on the username-aliases branch"
+       environment = "Development"
+       id          = (known after apply)
+       is_default  = false
+       name        = "dev-username-aliases"
+       owner_id    = (known after apply)
+       owner_uuid  = (known after apply)
+       purpose     = "Web Application"
+       resources   = (known after apply)
+       updated_at  = (known after apply)
    }

  # module.app.digitalocean_app.app will be created
+   resource "digitalocean_app" "app" {
+       active_deployment_id = (known after apply)
+       created_at           = (known after apply)
+       default_ingress      = (known after apply)
+       id                   = (known after apply)
+       live_url             = (known after apply)
+       project_id           = (known after apply)
+       updated_at           = (known after apply)
+       urn                  = (known after apply)

+       dedicated_ips (known after apply)

+       spec {
+           domains  = (known after apply)
+           features = [
+               "buildpack-stack=ubuntu-22",
            ]
+           name     = "dev-username-aliases"
+           region   = "sfo"

+           alert {
+               disabled = false
+               rule     = "DEPLOYMENT_FAILED"
            }

+           domain (known after apply)

+           ingress (known after apply)

+           service {
+               dockerfile_path    = "Dockerfile"
+               http_port          = 8080
+               instance_count     = 1
+               instance_size_slug = "apps-s-1vcpu-0.5gb"
+               internal_ports     = (known after apply)
+               name               = "app"
+               run_command        = (known after apply)

+               github {
+                   branch         = "username-aliases"
+                   deploy_on_push = true
+                   repo           = "scidsg/hushline"
                }

+               health_check {
+                   http_path = "/health.json"
                }

+               routes (known after apply)
            }
+           service {
+               http_port          = (known after apply)
+               instance_count     = 1
+               instance_size_slug = "apps-s-1vcpu-0.5gb"
+               internal_ports     = [
+                   5432,
                ]
+               name               = "db"
+               run_command        = (known after apply)

+               image {
+                   registry      = "library"
+                   registry_type = "DOCKER_HUB"
+                   repository    = "postgres"
+                   tag           = "16.4-alpine3.20"

+                   deploy_on_push (known after apply)
                }

+               routes (known after apply)
            }
        }
    }

  # module.app.random_password.local_db_password will be created
+   resource "random_password" "local_db_password" {
+       bcrypt_hash      = (sensitive value)
+       id               = (known after apply)
+       length           = 16
+       lower            = true
+       min_lower        = 0
+       min_numeric      = 0
+       min_special      = 0
+       min_upper        = 0
+       number           = true
+       numeric          = true
+       override_special = "!#$%&*()-_=+[]{}<>:?"
+       result           = (sensitive value)
+       special          = true
+       upper            = true
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Changes to Outputs:
+   app_live_url = (known after apply)

✅ Plan applied in Deploy/Destroy Branch Dev Environment #277

Outputs
app_live_url = "https://dev-username-aliases-4y3kg.ondigitalocean.app"

Copy link
Collaborator

@jeremywmoore jeremywmoore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took an initial pass through. The remote dev environment won't work until the PR has the corresponding migrations which you can generate via make revision message="username_aliases"

Makefile Outdated Show resolved Hide resolved
hushline/model.py Show resolved Hide resolved
hushline/model.py Show resolved Hide resolved
hushline/model.py Show resolved Hide resolved
hushline/routes.py Show resolved Hide resolved
hushline/routes.py Outdated Show resolved Hide resolved
hushline/routes.py Outdated Show resolved Hide resolved
hushline/routes.py Outdated Show resolved Hide resolved
hushline/routes.py Outdated Show resolved Hide resolved
hushline/settings/__init__.py Outdated Show resolved Hide resolved
@jeremywmoore jeremywmoore added the destroy destroy dev deployment label Sep 18, 2024
@github-actions github-actions bot removed deploy create dev deployment destroy destroy dev deployment labels Sep 18, 2024
scripts/dev_data.py Dismissed Show dismissed Hide dismissed
@brassy-endomorph brassy-endomorph force-pushed the username-aliases branch 2 times, most recently from 961660f to 8b25ad1 Compare September 19, 2024 10:14
Copy link

github-actions bot commented Sep 19, 2024

Terraform plan in terraform/dev in the hushline-dev-username-aliases workspace

With variables

branch = "username-aliases"
name   = "dev-username-aliases"
Plan: 3 to add, 0 to change, 0 to destroy. Changes to Outputs.
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+   create

Terraform will perform the following actions:

  # digitalocean_project.hush_line_dev will be created
+   resource "digitalocean_project" "hush_line_dev" {
+       created_at  = (known after apply)
+       description = "Development instance based on the username-aliases branch"
+       environment = "Development"
+       id          = (known after apply)
+       is_default  = false
+       name        = "dev-username-aliases"
+       owner_id    = (known after apply)
+       owner_uuid  = (known after apply)
+       purpose     = "Web Application"
+       resources   = (known after apply)
+       updated_at  = (known after apply)
    }

  # module.app.digitalocean_app.app will be created
+   resource "digitalocean_app" "app" {
+       active_deployment_id = (known after apply)
+       created_at           = (known after apply)
+       default_ingress      = (known after apply)
+       id                   = (known after apply)
+       live_url             = (known after apply)
+       project_id           = (known after apply)
+       updated_at           = (known after apply)
+       urn                  = (known after apply)

+       dedicated_ips (known after apply)

+       spec {
+           domains  = (known after apply)
+           features = [
+               "buildpack-stack=ubuntu-22",
            ]
+           name     = "dev-username-aliases"
+           region   = "sfo"

+           alert {
+               disabled = false
+               rule     = "DEPLOYMENT_FAILED"
            }

+           domain (known after apply)

+           ingress (known after apply)

+           service {
+               dockerfile_path    = "Dockerfile"
+               http_port          = 8080
+               instance_count     = 1
+               instance_size_slug = "apps-s-1vcpu-0.5gb"
+               internal_ports     = (known after apply)
+               name               = "app"
+               run_command        = (known after apply)

+               github {
+                   branch         = "username-aliases"
+                   deploy_on_push = true
+                   repo           = "scidsg/hushline"
                }

+               health_check {
+                   http_path = "/health.json"
                }

+               routes (known after apply)
            }
+           service {
+               http_port          = (known after apply)
+               instance_count     = 1
+               instance_size_slug = "apps-s-1vcpu-0.5gb"
+               internal_ports     = [
+                   5432,
                ]
+               name               = "db"
+               run_command        = (known after apply)

+               image {
+                   registry      = "library"
+                   registry_type = "DOCKER_HUB"
+                   repository    = "postgres"
+                   tag           = "16.4-alpine3.20"

+                   deploy_on_push (known after apply)
                }

+               routes (known after apply)
            }
        }
    }

  # module.app.random_password.local_db_password will be created
+   resource "random_password" "local_db_password" {
+       bcrypt_hash      = (sensitive value)
+       id               = (known after apply)
+       length           = 16
+       lower            = true
+       min_lower        = 0
+       min_numeric      = 0
+       min_special      = 0
+       min_upper        = 0
+       number           = true
+       numeric          = true
+       override_special = "!#$%&*()-_=+[]{}<>:?"
+       result           = (sensitive value)
+       special          = true
+       upper            = true
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Changes to Outputs:
+   app_live_url = (known after apply)

✅ Plan applied in Deploy/Destroy Branch Dev Environment #285

Outputs
app_live_url = "https://dev-username-aliases-vh4ix.ondigitalocean.app"

Copy link

🚀 App successfully deployed to https://dev-username-aliases-vh4ix.ondigitalocean.app!

Copy link
Collaborator

@jeremywmoore jeremywmoore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure to follow up on future PRs with:

  • alembic migrations run during CI
  • UUIDs instead of DB ids for messages, users, aliases
  • don't autocommit username changes

@glenn-sorrentino glenn-sorrentino dismissed their stale review September 19, 2024 14:45

Make way to merge

@brassy-endomorph brassy-endomorph merged commit f31d5d3 into main Sep 19, 2024
9 checks passed
@brassy-endomorph brassy-endomorph deleted the username-aliases branch September 19, 2024 14:45
@github-actions github-actions bot removed the deploy create dev deployment label Sep 19, 2024
@brassy-endomorph
Copy link
Collaborator Author

Tickets for followups:

alembic migrations run during CI

#555
#602

UUIDs instead of DB ids for messages, users, aliases

#528
#603

don't autocommit username changes

#604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Username Aliases
3 participants