ratemyclient/lib/my_first_elixir_vibe_code/accounts/contractor.ex
Kevin Sivic 9ece312442 Initial commit: RateMyClient™ Phoenix application
Features:
- User registration and authentication with email/password
- Admin login with username-based authentication (separate from regular users)
- Review system for contractors to rate clients
- Star rating system with review forms
- Client identification with private data protection
- Contractor registration with document verification
- Admin dashboard for review management
- Contact form (demo, non-functional)
- Responsive navigation with DaisyUI components
- Docker Compose setup for production deployment
- PostgreSQL database with Ecto migrations
- High Vis color scheme (dark background with safety orange/green)

Admin credentials: username: admin, password: admin123

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 21:30:50 -05:00

33 lines
1.1 KiB
Elixir

defmodule MyFirstElixirVibeCode.Accounts.Contractor do
use Ecto.Schema
import Ecto.Changeset
schema "contractors" do
field :name, :string
field :email, :string
field :company_name, :string
field :municipal_registration_proof, :string
field :insurance_proof, :string
field :registration_status, :string, default: "pending"
field :verified_at, :utc_datetime
timestamps(type: :utc_datetime)
end
@doc false
def changeset(contractor, attrs) do
contractor
|> cast(attrs, [:name, :email, :company_name])
|> validate_required([:name, :email, :company_name])
end
@doc false
def registration_changeset(contractor, attrs) do
contractor
|> cast(attrs, [:name, :email, :company_name, :municipal_registration_proof, :insurance_proof])
|> validate_required([:name, :email, :company_name, :municipal_registration_proof, :insurance_proof])
|> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, message: "must be a valid email")
|> unique_constraint(:email)
|> put_change(:registration_status, "pending")
end
end