Skip to content
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

User messaging #69

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

User messaging #69

wants to merge 29 commits into from

Conversation

jmast02
Copy link
Collaborator

@jmast02 jmast02 commented Jan 16, 2020

Single User to User messaging functionality. Still features to work on to make user experience friendlier.

return render(request, template_name, {'message_list': message_list})


@login_required
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

return render(request, template_name, {'message_list': message_list})


@login_required
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

return render(request, template_name, {'inbox_count': inbox_count(user=request.user)})


@login_required
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.



@login_required
def compose(request):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function compose has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.



@login_required
def reply(request, message_id):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reply has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

if parent.sender != request.user and parent.recipient != request.user:
raise Http404

if request.method == 'POST':
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.


context = {'message': message, 'reply_form': None}
if message.recipient == user:
form = form_class(initial={
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

@jmast02
Copy link
Collaborator Author

jmast02 commented Jan 16, 2020

Might be better off converting these FBVs to CBVs to reduce cognitive complexity and reduce identical code blocks?



@login_required
def reply(request, message_id):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function reply has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.


"""Views for Inbox OR Outbox OR Trash"""

if key == 'inbox':
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

message_list = Message.objects.inbox_for(request.user)
template_name = 'messaging/inbox.html'
return render(request, template_name, {'message_list': message_list})
elif key == 'outbox':
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

message_list = Message.objects.outbox_for(request.user)
template_name = 'messaging/outbox.html'
return render(request, template_name, {'message_list': message_list})
elif key == 'trash':
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants