-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Espace réutilisateur : formulaire pour ajouter des données améliorées (…
- Loading branch information
1 parent
9919d1b
commit e016e65
Showing
14 changed files
with
392 additions
and
17 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 |
---|---|---|
|
@@ -54,3 +54,7 @@ form.search-followed-datasets { | |
.align-right { | ||
text-align: right; | ||
} | ||
|
||
form.full-width { | ||
max-width: 100%; | ||
} |
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,30 @@ | ||
defmodule DB.ReuserImprovedData do | ||
@moduledoc """ | ||
Represents improved static data shared by reusers. | ||
""" | ||
use Ecto.Schema | ||
use TypedEctoSchema | ||
import Ecto.Changeset | ||
|
||
typed_schema "reuser_improved_data" do | ||
belongs_to(:dataset, DB.Dataset) | ||
belongs_to(:resource, DB.Resource) | ||
belongs_to(:contact, DB.Contact) | ||
belongs_to(:organization, DB.Organization, type: :string) | ||
field(:download_url, :string) | ||
timestamps(type: :utc_datetime_usec) | ||
end | ||
|
||
def changeset(%__MODULE__{} = struct, attrs \\ %{}) do | ||
fields = [:dataset_id, :resource_id, :contact_id, :organization_id, :download_url] | ||
|
||
struct | ||
|> cast(attrs, fields) | ||
|> validate_required(fields) | ||
|> assoc_constraint(:dataset) | ||
|> assoc_constraint(:resource) | ||
|> assoc_constraint(:contact) | ||
|> assoc_constraint(:organization) | ||
|> unique_constraint([:resource_id, :organization_id]) | ||
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
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
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
18 changes: 18 additions & 0 deletions
18
apps/transport/priv/repo/migrations/20250204084455_reuser_improved_data.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,18 @@ | ||
defmodule DB.Repo.Migrations.ReuserImprovedData do | ||
use Ecto.Migration | ||
|
||
def change do | ||
create table(:reuser_improved_data) do | ||
add(:dataset_id, references(:dataset, on_delete: :delete_all), null: false) | ||
add(:resource_id, references(:resource, on_delete: :delete_all), null: false) | ||
add(:contact_id, references(:contact, on_delete: :delete_all), null: false) | ||
add(:organization_id, references(:organization, type: :string, on_delete: :delete_all), null: false) | ||
add(:download_url, :string, null: false) | ||
timestamps(type: :utc_datetime_usec) | ||
end | ||
|
||
create(index(:reuser_improved_data, [:dataset_id])) | ||
create(index(:reuser_improved_data, [:organization_id])) | ||
create(unique_index(:reuser_improved_data, [:resource_id, :organization_id])) | ||
end | ||
end |
Oops, something went wrong.