Prepare for the removal of Check.user_id and Channel.user_id

This commit is contained in:
Pēteris Caune 2019-01-18 16:44:09 +02:00
parent e1b999e83a
commit caf6668478
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
3 changed files with 5 additions and 6 deletions

View File

@ -170,9 +170,8 @@ class Check(models.Model):
return "up"
def assign_all_channels(self):
if self.user:
channels = Channel.objects.filter(user=self.user)
self.channel_set.add(*channels)
channels = Channel.objects.filter(project=self.project)
self.channel_set.add(*channels)
def tags_list(self):
return [t.strip() for t in self.tags.split(" ") if t.strip()]
@ -293,7 +292,7 @@ class Channel(models.Model):
}
def assign_all_checks(self):
checks = Check.objects.filter(user=self.user)
checks = Check.objects.filter(project=self.project)
self.checks.add(*checks)
def make_token(self):

View File

@ -374,7 +374,7 @@ class Sms(HttpTransport):
return check.status != "down"
def notify(self, check):
profile = Profile.objects.for_user(self.channel.user)
profile = Profile.objects.for_user(self.channel.project.owner)
if not profile.authorize_sms():
return "Monthly SMS limit exceeded"

View File

@ -148,7 +148,7 @@ def status(request, username):
if not _has_access(request, username):
raise Http404("not found")
checks = list(Check.objects.filter(user__username=username))
checks = list(Check.objects.filter(project__owner__username=username))
details = []
for check in checks: