-
Notifications
You must be signed in to change notification settings - Fork 0
Feature allow employee to join project #21
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2fd0dd7
Add form for project joining feature
maciejSamerdak 8a51fff
Add join feature related GUI text for report list view
maciejSamerdak a2f365f
Update report list view for project join feature support
maciejSamerdak 5a00f3d
Add script for join form's popup in report list
maciejSamerdak c699eb4
Add feature to template in form of a pop-up window
maciejSamerdak 3ef31a9
Limit project choice in report detail view
maciejSamerdak dbc9487
Add unit tests for join feature
maciejSamerdak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,12 @@ | ||
| from django import forms | ||
| from django.db.models import QuerySet | ||
|
|
||
|
|
||
| class ProjectJoinForm(forms.Form): | ||
|
|
||
| projects = forms.ChoiceField(choices=[]) | ||
|
|
||
| def __init__(self, queryset, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| assert isinstance(queryset, QuerySet) | ||
| self.fields['projects'].choices = [(project.id, project.name) for project in queryset] |
This file contains hidden or 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 @@ | ||
| $(function () { | ||
| $("#dialog").dialog ({ | ||
| modal: true, | ||
| autoOpen: false, | ||
| buttons : [ | ||
| { | ||
| text: join_discard_text, | ||
| click: function () { | ||
| $(this).dialog('close'); | ||
| } | ||
| } | ||
| ] | ||
| }).prev().find(".ui-dialog-titlebar-close").hide (); | ||
|
|
||
| $("#opener").click(function () { | ||
| $("#dialog").dialog('open'); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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,25 @@ | ||
| import datetime | ||
| from django.test import TestCase | ||
|
|
||
| from employees.forms import ProjectJoinForm | ||
| from managers.models import Project | ||
|
|
||
|
|
||
| class ProjectJoinFormTests(TestCase): | ||
| def test_project_join_form_should_create_choice_field_with_project_name_and_id_based_on_queryset_provided_in_constructor(self): | ||
| queryset_length = 10 | ||
| for i in range(queryset_length): | ||
| project = Project( | ||
| name=f"Test Project {i}", | ||
| start_date=datetime.datetime.now(), | ||
| ) | ||
| project.full_clean() | ||
| project.save() | ||
| queryset = Project.objects.all() | ||
| form = ProjectJoinForm(queryset) | ||
| choices = form.fields['projects'].choices | ||
| self.assertIsNotNone(choices) | ||
| self.assertEqual(len(choices), queryset_length) | ||
| for i in range(queryset_length): | ||
| self.assertEqual(choices[i][0], queryset[i].id) | ||
| self.assertEqual(choices[i][1], queryset[i].name) |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This could be changed to some kind of Enum and reused in place where it is assigned to request. Thanks to this will not stop working if it will be changed in another place
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.
You mean the 'join' string? It's an id from HTML template, so I'd say it's name is rather irrelevant, but I could supply some sort of constant for it. The question is whether it's worth the extra effort?
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.
Yea, you're right. It won't be necessary :)