コード例 #1
0
def add_email(request):
    if request.method == "POST":
        form = AddEmailForm(request.POST)
        if form.is_valid():
            channel = Channel(project=request.project, kind="email")
            channel.value = json.dumps({
                "value": form.cleaned_data["value"],
                "up": form.cleaned_data["up"],
                "down": form.cleaned_data["down"]
            })
            channel.save()

            channel.assign_all_checks()

            if settings.EMAIL_USE_VERIFICATION:
                channel.send_verify_link()
            else:
                # In self-hosted setting, administator has the option to
                # disable the email verification step.
                channel.email_verified = True
                channel.save()

            return redirect("hc-channels")
    else:
        form = AddEmailForm()

    ctx = {
        "page": "channels",
        "project": request.project,
        "use_verification": settings.EMAIL_USE_VERIFICATION,
        "form": form
    }
    return render(request, "integrations/add_email.html", ctx)
コード例 #2
0
def _make_user(email, with_project=True):
    username = str(uuid.uuid4())[:30]
    user = User(username=username, email=email)
    user.set_unusable_password()
    user.save()

    project = None
    if with_project:
        project = Project(owner=user)
        project.badge_key = user.username
        project.save()

        check = Check(project=project)
        check.name = "My First Check"
        check.save()

        channel = Channel(project=project)
        channel.kind = "email"
        channel.value = email
        channel.email_verified = True
        channel.save()

        channel.checks.add(check)

    # Ensure a profile gets created
    profile = Profile.objects.for_user(user)
    profile.current_project = project
    profile.save()

    return user
コード例 #3
0
def _make_user(email, with_project=True):
    # Generate username from email in a deterministic way.
    # Since the database has an uniqueness constraint on username,
    # this makes sure that emails also are unique.
    username = str(uuid.uuid3(NAMESPACE_HC, email))
    user = User(username=username, email=email)
    user.set_unusable_password()
    user.save()

    project = None
    if with_project:
        project = Project(owner=user)
        project.badge_key = user.username
        project.save()

        check = Check(project=project)
        check.name = "My First Check"
        check.save()

        channel = Channel(project=project)
        channel.kind = "email"
        channel.value = email
        channel.email_verified = True
        channel.save()

        channel.checks.add(check)

    # Ensure a profile gets created
    profile = Profile.objects.for_user(user)
    profile.current_project = project
    profile.save()

    return user
コード例 #4
0
ファイル: views.py プロジェクト: bobocola/healthchecks
def _make_user(email):
    username = str(uuid.uuid4())[:30]
    user = User(username=username, email=email)
    user.save()

    channel = Channel()
    channel.user = user
    channel.kind = "email"
    channel.value = email
    channel.email_verified = True
    channel.save()

    return user
コード例 #5
0
def _make_user(email):
    username = str(uuid.uuid4())[:30]
    user = User(username=username, email=email)
    user.save()

    channel = Channel()
    channel.user = user
    channel.kind = "email"
    channel.value = email
    channel.email_verified = True
    channel.save()

    return user
コード例 #6
0
ファイル: makechannels.py プロジェクト: cecepm/healthchecks
    def handle(self, *args, **options):

        for user in User.objects.all():
            q = Channel.objects.filter(user=user)
            q = q.filter(kind="email", email_verified=True, value=user.email)
            if q.count() > 0:
                continue

            print("Creating default channel for %s" % user.email)
            channel = Channel(user=user)
            channel.kind = "email"
            channel.value = user.email
            channel.email_verified = True
            channel.save()

            channel.checks.add(*Check.objects.filter(user=user))
コード例 #7
0
ファイル: views.py プロジェクト: niti15/heroku
def _make_user(email):
    username = str(uuid.uuid4())[:30]
    user = User(username=username, email=email)
    user.set_unusable_password()
    user.save()

    # Ensure a profile gets created
    Profile.objects.for_user(user)

    channel = Channel()
    channel.user = user
    channel.kind = "email"
    channel.value = email
    channel.email_verified = True
    channel.save()

    return user
コード例 #8
0
def _make_user(email):
    username = str(uuid.uuid4())[:30]
    user = User(username=username, email=email)
    user.set_unusable_password()
    user.save()

    profile = Profile(user=user)
    profile.save()

    channel = Channel()
    channel.user = user
    channel.kind = "email"
    channel.value = email
    channel.email_verified = True
    channel.save()

    return user
コード例 #9
0
ファイル: views.py プロジェクト: haswalt/healthchecks
def _make_user(email):
    username = str(uuid.uuid4())[:30]
    user = User(username=username, email=email)
    user.set_unusable_password()
    user.save()

    profile = Profile(user=user)
    profile.save()

    channel = Channel()
    channel.user = user
    channel.kind = "email"
    channel.value = email
    channel.email_verified = True
    channel.save()

    return user
コード例 #10
0
ファイル: views.py プロジェクト: cogzidel/healthchecks
def _make_user(email):
    username = str(uuid.uuid4())[:30]
    user = User(username=username, email=email)
    user.set_unusable_password()
    user.save()

    # Ensure a profile gets created
    Profile.objects.for_user(user)

    channel = Channel()
    channel.user = user
    channel.kind = "email"
    channel.value = email
    channel.email_verified = True
    channel.save()

    return user
コード例 #11
0
def add_email(request, code):
    project = _get_project_for_user(request, code)

    if request.method == "POST":
        form = AddEmailForm(request.POST)
        if form.is_valid():
            channel = Channel(project=project, kind="email")
            channel.value = json.dumps(
                {
                    "value": form.cleaned_data["value"],
                    "up": form.cleaned_data["up"],
                    "down": form.cleaned_data["down"],
                }
            )
            channel.save()

            channel.assign_all_checks()

            is_own_email = form.cleaned_data["value"] == request.user.email
            if is_own_email or not settings.EMAIL_USE_VERIFICATION:
                # If user is subscribing *their own* address
                # we can skip the verification step.

                # Additionally, in self-hosted setting, administator has the
                # option to disable the email verification step altogether.

                channel.email_verified = True
                channel.save()
            else:
                channel.send_verify_link()

            return redirect("hc-p-channels", project.code)
    else:
        form = AddEmailForm()

    ctx = {
        "page": "channels",
        "project": project,
        "use_verification": settings.EMAIL_USE_VERIFICATION,
        "form": form,
    }
    return render(request, "integrations/add_email.html", ctx)