Skip to content

Commit

Permalink
Merge pull request #23 from andela/ft-different-alert-allocation-1537…
Browse files Browse the repository at this point in the history
…28013

Ft different alert allocation 153728013
  • Loading branch information
hadijahkyampeire committed Jan 30, 2018
2 parents 7809a76 + 7be2849 commit 8ece198
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 18 deletions.
3 changes: 2 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
web: python manage.py migrate & python manage.py ensuretriggers & python manage.py sendalerts & python manage.py sendreports & gunicorn hc.wsgi --log-file -

web: python manage.py makemigrations & python manage.py migrate & python manage.py ensuretriggers & python manage.py sendalerts & gunicorn hc.wsgi --log-file -
4 changes: 2 additions & 2 deletions hc/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def invite(self, user):
member.save()
# Switch the invited user over to the new team so they
# notice the new team on next visit:
user.profile.current_team = self
user.profile.save()
# user.profile.current_team = self
# user.profile.save()

user.profile.send_instant_login_link(self)

Expand Down
12 changes: 5 additions & 7 deletions hc/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,24 @@ def profile(request):
user = User.objects.get(email=email)
except User.DoesNotExist:
user = _make_user(email)
# add the user
profile.invite(user)
messages.success(request, "Invitation to %s sent!" % email)

# get the checks selected and add them to invited
# user as checks they have permissions on
# member = profile.objects.get(user=user)
user_profile = Profile.objects.get(user=user)
member = Member()


for key, value in dict(request.POST).items():
if value[0] == 'on':
# this means the check is selected, save the key
# in a table where team checks are saved
member = Member()
member.user = user
member.team = user_profile
member.hcheck = key
member.save()

# add the user

elif "remove_team_member" in request.POST:
form = RemoveTeamMemberForm(request.POST)
if form.is_valid():
Expand All @@ -201,8 +200,7 @@ def profile(request):
farewell_user.profile.current_team = None
farewell_user.profile.save()

Member.objects.filter(team=profile,
user=farewell_user).delete()
Member.objects.filter(user=farewell_user).delete()

messages.info(request, "%s removed from team!" % email)
elif "set_team_name" in request.POST:
Expand Down
12 changes: 7 additions & 5 deletions hc/front/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ def team_checks(request):
q = Member.objects.filter(user=request.user)
qs = list(q)
checks = []
for row in qs:
ch = Check.objects.filter(name=row.hcheck).order_by('created')
checks = list(ch)

for mem in qs:
ch = Check.objects.filter(name=mem.hcheck).first()
if ch is not None:
checks.append(ch)

counter = Counter()
down_tags, grace_tags = set(), set()

for check in checks:
status = check.get_status()
for tag in check.tags_list():
Expand Down Expand Up @@ -67,7 +69,7 @@ def team_checks(request):
def my_checks(request):
q = Check.objects.filter(user=request.team.user).order_by("created")
checks = list(q)

print(checks)
counter = Counter()
down_tags, grace_tags = set(), set()
for check in checks:
Expand Down
3 changes: 2 additions & 1 deletion hc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@

USE_TZ = True

SITE_ROOT = "https://hclogros.herokuapp.com"
SITE_ROOT = "https://hc-invite-member.herokuapp.com"
# SITE_ROOT = "http://localhost:8000"
SITE_NAME = "Health Checks"

PING_ENDPOINT = SITE_ROOT + "/ping/"
Expand Down
1 change: 1 addition & 0 deletions templates/accounts/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ <h4 class="remove-check-title">Invite a Team Member</h4>
<ul>
<li>Team Members can create and manage Checks and Integrations</li>
<li>Only the team owner (you) can view and edit billing settings</li>
<li>Team Members can only access the checks assigned to them</li>
</ul>
<div class="form-group">
<label for="itm-email" class="col-sm-2 control-label">Email</label>
Expand Down
4 changes: 2 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@
<li><a href="{% url 'hc-profile' %}">Account Settings</a></li>
<li role="separator" class="divider"></li>

{% for team in request.teams %}
<!-- {% for team in request.teams %}
<li class="dropdown-header">{{ team }}</li>
<li>
<a href="{% url 'hc-switch-team' team.user.username %}">Checks</a>
</li>
<li role="separator" class="divider"></li>
{% endfor %}
{% endfor %} -->

<li><a href="{% url 'hc-logout' %}">Log Out</a></li>
</ul>
Expand Down
11 changes: 11 additions & 0 deletions templates/front/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,17 @@ <h2>When Alerts Are Sent</h2>
sends you an alert.
</td>
</tr>
<tr>
<td>
<span class="status icon-down" style="color:#e2d948"></span>
</td>
<td>
<strong>Often.</strong>
Time between last ping and next ping is less than <strong>Reversed-Grace-Period</strong>.
When check is said to be running "often", healthchecks.io
sends you an alert.
</td>
</tr>
</table>

{% endblock %}

0 comments on commit 8ece198

Please sign in to comment.