Skip to content

Commit

Permalink
Merge pull request #149 from ecxia/feature/availability
Browse files Browse the repository at this point in the history
Allow users to deactivate discovery and incoming requests
  • Loading branch information
rifferreinert authored Jul 19, 2020
2 parents dfa8ac3 + d5a8260 commit 89bb9e4
Show file tree
Hide file tree
Showing 11 changed files with 458 additions and 81 deletions.
2 changes: 1 addition & 1 deletion buddy_mentorship/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BuddyRequestAdmin(admin.ModelAdmin):

@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
fields = ["user", "bio"]
fields = ["user", "bio", "looking_for_mentors", "looking_for_mentees"]


@admin.register(Skill)
Expand Down
4 changes: 2 additions & 2 deletions buddy_mentorship/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class ProfileEditForm(forms.Form):
last_name = forms.CharField(max_length=255, required=False)
email = forms.EmailField()
bio = forms.CharField(required=False, widget=forms.Textarea)
help_wanted = forms.BooleanField(required=False)
can_help = forms.BooleanField(required=False)
looking_for_mentors = forms.BooleanField(required=False)
looking_for_mentees = forms.BooleanField(required=False)


class SkillForm(forms.Form):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.1a1 on 2020-07-17 02:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("buddy_mentorship", "0012_auto_20200704_0232"),
]

operations = [
migrations.AddField(
model_name="profile",
name="looking_for_mentees",
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name="profile",
name="looking_for_mentors",
field=models.BooleanField(default=True),
),
]
2 changes: 2 additions & 0 deletions buddy_mentorship/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class Profile(models.Model):

user = models.ForeignKey(User, on_delete=models.CASCADE)
bio = models.TextField(null=True, blank=True)
looking_for_mentors = models.BooleanField(null=False, default=True)
looking_for_mentees = models.BooleanField(null=False, default=True)

def __str__(self):
return f"Profile for {self.user.email}"
Expand Down
4 changes: 4 additions & 0 deletions buddy_mentorship/static/js/tooltip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
29 changes: 28 additions & 1 deletion buddy_mentorship/templates/buddy_mentorship/edit_profile.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'buddy_mentorship/base.html' %}

{% load static %}

{% block title %}
Edit Profile
{% endblock title %}
Expand All @@ -24,9 +26,34 @@
<label for="id_email">Email</label>
<input class="form-control" value="{{email}}"type="email" name="email" required id="id_email">
</div>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="looking_for_mentors" {% if looking_for_mentors %} checked {% endif %} id="lookingForMentorsCheck" >
<label class="form-check-label" for="lookingForMentorsCheck">
I am actively looking for mentors
<svg class="text-info" data-toggle="tooltip" title="Check this box if you want potential mentors to be able to find you in search and send mentorship offers." data-placement="right" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-info-circle-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412l-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM8 5.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/>
</svg>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="looking_for_mentees" {% if looking_for_mentees %} checked {% endif %} id="lookingForMenteesCheck">
<label class="form-check-label" for="lookingForMenteesCheck">
I am actively looking for mentees
<svg class="text-info" data-toggle="tooltip" title="Check this box if you want potential mentees to be able to find you in search and send mentorship requests." data-placement="right" width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-info-circle-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412l-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM8 5.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/>
</svg>
</label>
</div>
</div>

<button class="btn btn-primary" type="submit">Save</button>
</form>

{% block tooltip_js %}
<script src="{% static "js/tooltip.js" %}">
</script>
{% endblock tooltip_js %}

{% endblock content %}

{% endblock content %}
2 changes: 1 addition & 1 deletion buddy_mentorship/templates/buddy_mentorship/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h1 class="display-5 text-center text-md-left">FAQ</h1>
all participants are required to conform to ChiPy's Code of Conduct at all times.
Read our full Code of Conduct <a href="https://www.chipy.org/pages/conduct/">here</a>.
If you have any concerns you should immediately contact ChiPy organizers
in-person, on Slack, or text/call. For text/call, the On-Call responder can be reached at 1+201-778-4075.
in-person, on Slack, or text/call. For text/call, the On-Call responder can be reached at 1+201-778-4075.
</p>

<p>Is this the same thing as ChiPy's Mentorship Program?</p>
Expand Down
40 changes: 36 additions & 4 deletions buddy_mentorship/templates/buddy_mentorship/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ <h1>
<div class="card-title h5">
Want Help
</div>
{% if profile.looking_for_mentors %}
<span class="badge badge-success" id="lookingForMentorsBadge">Actively Looking for Mentors</span>
{% endif %}
{% if not profile.looking_for_mentors %}
<span class="badge badge-secondary" id="notLookingForMentorsBadge">Not Actively Looking for Mentors</span>
{% endif %}
{% comment %} </div> {% endcomment %}
<div class="card-text">
<ul class="list-group list-group-flush">
{% for experience in profile.get_help_wanted %}
Expand Down Expand Up @@ -89,9 +96,10 @@ <h1>
{% endfor %}
{% if request.user == profile.user %}
{% if not profile.get_help_wanted %}
<p></p>
<div class="alert alert-warning" role="alert">
<p>Your profile has no skills you want help with.</p>
<p>Adding skills that you want help with allows you to <b>send mentorship offers</b> and allows people looking for mentees to <b>find you via search</b> and <b>send you mentorship offers</b>.</p>
<p>Adding skills that you want help with allows you to <b>send mentorship offers</b> and is needed for people looking for mentees to <b>find you via search</b> and <b>send you mentorship offers</b>.</p>
</div>
{% endif %}
<li class="list-group-item d-flex align-items-left">
Expand All @@ -117,6 +125,12 @@ <h1>
<div class="card-title h5">
Can Help
</div>
{% if profile.looking_for_mentees %}
<span class="badge badge-success" id="lookingForMenteesBadge">Actively Looking for Mentees</span>
{% endif %}
{% if not profile.looking_for_mentees %}
<span class="badge badge-secondary" id="notLookingForMenteesBadge">Not Actively Looking for Mentees</span>
{% endif %}
<div class="card-text">
<ul class="list-group list-group-flush">
{% for experience in profile.get_can_help %}
Expand Down Expand Up @@ -148,9 +162,10 @@ <h1>
{% endfor %}
{% if request.user == profile.user %}
{% if not profile.get_can_help %}
<p></p>
<div class="alert alert-warning" role="alert">
<p>Your profile has no skills you can help with.</p>
<p>Adding skills that you can help with allows people looking for mentors to <b>find you via search</b> and <b>send you mentorship requests</b>, and allows you to <b>send mentorship offers</b>.</p>
<p>Adding skills that you can help with is needed for people looking for mentors to <b>find you via search</b> and <b>send you mentorship requests</b>, and allows you to <b>send mentorship offers</b>.</p>
</div>
{% endif %}
<li class="list-group-item d-flex align-items-left">
Expand Down Expand Up @@ -212,7 +227,15 @@ <h1>
</div>
{% endif %}

{% if not can_request and existing_request_from_user is None and existing_offer_to_user is None and user_profile != profile %}
{% if cannot_request_not_looking %}
<div class="alert alert-info" role="alert">
<p>
You are not able to request help from this user because they are not actively looking for mentees.
</p>
</div>
{% endif %}

{% if cannot_request_no_skills %}
<div class="alert alert-info" role="alert">
<p>
You are not able to request help from this user. This may be because you have not added a skill you want help with or
Expand Down Expand Up @@ -240,7 +263,15 @@ <h1>

{% endif %}

{% if not can_offer and existing_request_to_user is None and existing_offer_from_user is None and user_profile != profile %}
{% if cannot_offer_not_looking %}
<div class="alert alert-info" role="alert">
<p>
You are not able to offer to mentor this user because they are not actively looking for mentors.
</p>
</div>
{% endif %}

{% if cannot_offer_no_skills %}
<div class="alert alert-info" role="alert">
<p>
You are not able to offer to mentor this user. This may be because you have not added a skill you can help with or
Expand All @@ -250,6 +281,7 @@ <h1>
{% endif %}
</div>
</div>

{% block map_js %}
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h4>Added:</h4>
</ul>
<h4>Changed:</h4>
<ul>
<li>Users can now toggle discoverability and inbound requests via "Actively looking for mentors" and "Actively looking for mentees" settings on profile.
<li>Going to a page that requires a login no longer auto redirects the user to Github.</li>
<li>Github link opens in new a tab.</li>
</ul>
Expand Down
Loading

0 comments on commit 89bb9e4

Please sign in to comment.