-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create crowdsource context & add login in plugin
- Loading branch information
Showing
11 changed files
with
375 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
ENVIRONMENT=development | ||
LOCAL_STORAGE_NAME=ogbvData | ||
API_URL=http://localhost:3000 | ||
API_URL=http://localhost:4000 | ||
MEDIA_URL=https://uli-media.tattle.co.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import axios from "axios"; | ||
import config from "./config"; | ||
|
||
const { API_URL } = config; | ||
|
||
export async function userLogin({email, password}){ | ||
|
||
console.log("INSIDE USERLOGIN: ") | ||
try { | ||
const response = await axios.post(`${API_URL}/api/auth/login`, { | ||
email, | ||
password | ||
}); | ||
console.log("RESPONSE IS: ",response) | ||
console.log('Login successful:', response.data); | ||
return response.data; | ||
} catch (error) { | ||
|
||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
defmodule UliCommunity.UserContribution do | ||
@moduledoc """ | ||
The UserContribution context. | ||
""" | ||
|
||
import Ecto.Query, warn: false | ||
alias UliCommunity.Repo | ||
|
||
alias UliCommunity.UserContribution.CrowdsourcedSlur | ||
|
||
@doc """ | ||
Returns the list of crowdsourced_slurs. | ||
## Examples | ||
iex> list_crowdsourced_slurs() | ||
[%CrowdsourcedSlur{}, ...] | ||
""" | ||
def list_crowdsourced_slurs do | ||
Repo.all(CrowdsourcedSlur) | ||
end | ||
|
||
@doc """ | ||
Gets a single crowdsourced_slur. | ||
Raises `Ecto.NoResultsError` if the Crowdsourced slur does not exist. | ||
## Examples | ||
iex> get_crowdsourced_slur!(123) | ||
%CrowdsourcedSlur{} | ||
iex> get_crowdsourced_slur!(456) | ||
** (Ecto.NoResultsError) | ||
""" | ||
def get_crowdsourced_slur!(id), do: Repo.get!(CrowdsourcedSlur, id) | ||
|
||
@doc """ | ||
Creates a crowdsourced_slur. | ||
## Examples | ||
iex> create_crowdsourced_slur(%{field: value}) | ||
{:ok, %CrowdsourcedSlur{}} | ||
iex> create_crowdsourced_slur(%{field: bad_value}) | ||
{:error, %Ecto.Changeset{}} | ||
""" | ||
def create_crowdsourced_slur(attrs \\ %{}) do | ||
%CrowdsourcedSlur{} | ||
|> CrowdsourcedSlur.changeset(attrs) | ||
|> Repo.insert() | ||
end | ||
|
||
@doc """ | ||
Updates a crowdsourced_slur. | ||
## Examples | ||
iex> update_crowdsourced_slur(crowdsourced_slur, %{field: new_value}) | ||
{:ok, %CrowdsourcedSlur{}} | ||
iex> update_crowdsourced_slur(crowdsourced_slur, %{field: bad_value}) | ||
{:error, %Ecto.Changeset{}} | ||
""" | ||
def update_crowdsourced_slur(%CrowdsourcedSlur{} = crowdsourced_slur, attrs) do | ||
crowdsourced_slur | ||
|> CrowdsourcedSlur.changeset(attrs) | ||
|> Repo.update() | ||
end | ||
|
||
@doc """ | ||
Deletes a crowdsourced_slur. | ||
## Examples | ||
iex> delete_crowdsourced_slur(crowdsourced_slur) | ||
{:ok, %CrowdsourcedSlur{}} | ||
iex> delete_crowdsourced_slur(crowdsourced_slur) | ||
{:error, %Ecto.Changeset{}} | ||
""" | ||
def delete_crowdsourced_slur(%CrowdsourcedSlur{} = crowdsourced_slur) do | ||
Repo.delete(crowdsourced_slur) | ||
end | ||
|
||
@doc """ | ||
Returns an `%Ecto.Changeset{}` for tracking crowdsourced_slur changes. | ||
## Examples | ||
iex> change_crowdsourced_slur(crowdsourced_slur) | ||
%Ecto.Changeset{data: %CrowdsourcedSlur{}} | ||
""" | ||
def change_crowdsourced_slur(%CrowdsourcedSlur{} = crowdsourced_slur, attrs \\ %{}) do | ||
CrowdsourcedSlur.changeset(crowdsourced_slur, attrs) | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
uli-community/lib/uli_community/user_contribution/crowdsourced_slur.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
defmodule UliCommunity.UserContribution.CrowdsourcedSlur do | ||
use Ecto.Schema | ||
import Ecto.Changeset | ||
|
||
schema "crowdsourced_slurs" do | ||
field :label, :string | ||
field :category, {:array, :string} | ||
field :level_of_severity, Ecto.Enum, values: [:low, :medium, :high] | ||
field :casual, :boolean, default: false | ||
field :appropriated, :boolean, default: false | ||
field :appropriation_context, :boolean, default: false | ||
field :meaning, :string | ||
|
||
timestamps(type: :utc_datetime) | ||
end | ||
|
||
@doc false | ||
def changeset(crowdsourced_slur, attrs) do | ||
crowdsourced_slur | ||
|> cast(attrs, [:label, :level_of_severity, :casual, :appropriated, :appropriation_context, :meaning, :category]) | ||
|> validate_required([:label, :level_of_severity, :casual, :appropriated, :appropriation_context, :meaning, :category]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
uli-community/priv/repo/migrations/20250120074709_create_crowdsourced_slurs.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule UliCommunity.Repo.Migrations.CreateCrowdsourcedSlurs do | ||
use Ecto.Migration | ||
|
||
def change do | ||
|
||
execute("CREATE TYPE level_of_severity AS ENUM ('low', 'medium', 'high')") | ||
create table(:crowdsourced_slurs) do | ||
add :label, :string | ||
add :level_of_severity, :level_of_severity | ||
add :casual, :boolean, default: false, null: false | ||
add :appropriated, :boolean, default: false, null: false | ||
add :appropriation_context, :boolean, default: false, null: false | ||
add :meaning, :text | ||
add :category, {:array, :string} | ||
|
||
timestamps(type: :utc_datetime) | ||
end | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
uli-community/test/support/fixtures/user_contribution_fixtures.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule UliCommunity.UserContributionFixtures do | ||
@moduledoc """ | ||
This module defines test helpers for creating | ||
entities via the `UliCommunity.UserContribution` context. | ||
""" | ||
|
||
@doc """ | ||
Generate a crowdsourced_slur. | ||
""" | ||
def crowdsourced_slur_fixture(attrs \\ %{}) do | ||
{:ok, crowdsourced_slur} = | ||
attrs | ||
|> Enum.into(%{ | ||
appropriated: true, | ||
appropriation_context: true, | ||
casual: true, | ||
category: ["option1", "option2"], | ||
label: "some label", | ||
level_of_severity: "some level_of_severity", | ||
meaning: "some meaning" | ||
}) | ||
|> UliCommunity.UserContribution.create_crowdsourced_slur() | ||
|
||
crowdsourced_slur | ||
end | ||
end |
Oops, something went wrong.