-
Notifications
You must be signed in to change notification settings - Fork 3
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
Allow users to apply for yearbook class #25
base: main
Are you sure you want to change the base?
Conversation
40dfdb5
to
eac31b7
Compare
cea538c
to
8269dbb
Compare
lib/yearbook/university.ex
Outdated
alias Yearbook.University.ClassStudent | ||
|
||
def create_class_student(attrs \\ %{}) do | ||
aluno = get_all_classes_students(attrs["student_id"], attrs["class_id"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aluno = get_all_classes_students(attrs["student_id"], attrs["class_id"]) | |
student = get_all_classes_students(attrs["student_id"], attrs["class_id"]) |
lib/yearbook/university.ex
Outdated
if aluno > 0 do | ||
{:error, %Ecto.Changeset{}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get this error. Can you explain it?
Also, you should send a message when throwing it, not a changeset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm verifying if a student is already in a class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just simply add a database constraint then
lib/yearbook/university.ex
Outdated
end | ||
end | ||
|
||
def get_all_classes_students(student_id, class_id) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_all_classes_students(student_id, class_id) do | |
def list_classes_students(student_id, class_id) do |
lib/yearbook/university.ex
Outdated
|> Enum.count() | ||
end | ||
|
||
def get_classes_students(student_id) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_classes_students(student_id) do | |
def list_student_classes(student_id) do |
@@ -19,4 +42,10 @@ defmodule YearbookWeb.YearbookLive.Show do | |||
|> assign(:page_title, class.degree.name) | |||
|> assign(:class, class)} | |||
end | |||
|
|||
def is_accepted?(student, class) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def is_accepted?(student, class) do | |
defp is_accepted?(student, class) do |
We should discuss if this is the better approach. Another approach that I can think of would be the course director supplying us the classes' students. |
I also agree with that, but that helps us verify if a student is a part of a yearbook class or not. |
But how would we know if the student is part of the class? If we are using the data given by the course director, shouldn't we make a script to seed the database and it's done? |
We will receive an excel sheet from course director with the necessary data and our task would be to cross-check if the users who applied are present in the sheet. We cannot automatically populate the database as we are unsure of the participants preferences, and even if everyone desires to be featured in the yearbook, also we don't know their application accounts. Additionally, I am developing this feature in a separate repository with the intention of eventually migrating it to the atomic repository. |
def create_class_student(attrs \\ %{}) do | ||
student = list_classes_student(attrs["student_id"], attrs["class_id"]) | ||
|
||
if student > 0 do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These types of verifications should be at the database level. Otherwise, you can not guaranty it.
Just make sure you have the unique index of [:student_id, :class_id] 💪
No description provided.