コード例 #1
0
ファイル: __init__.py プロジェクト: vinodpandey/appenlight
 def create_missing_channel(self, resource, channel_name):
     """
     Recreates alert channel for the owner of integration
     """
     if self.integration:
         if not self.integration.channel:
             channel = AlertChannel()
             channel.channel_name = channel_name
             channel.channel_validated = True
             channel.channel_value = resource.resource_id
             channel.integration_id = self.integration.id
             security_code = generate_random_string(10)
             channel.channel_json_conf = {"security_code": security_code}
             resource.owner.alert_channels.append(channel)
コード例 #2
0
ファイル: subscribers.py プロジェクト: ashishprsspl1/ETTTT
def application_created(app):
    webassets_dir = app.app.registry.settings.get('webassets.dir')
    js_hash = generate_random_string()
    css_hash = generate_random_string()
    if webassets_dir:
        js_hasher = hashlib.md5()
        css_hasher = hashlib.md5()
        for root, dirs, files in os.walk(webassets_dir):
            for name in files:
                filename = os.path.join(root, name)
                if name.endswith('css'):
                    with open(filename, 'r', encoding='utf8',
                              errors='replace') as f:
                        for line in f:
                            css_hasher.update(line.encode('utf8'))
                elif name.endswith('js'):
                    with open(filename, 'r', encoding='utf8',
                              errors='replace') as f:
                        for line in f:
                            js_hasher.update(line.encode('utf8'))
        js_hash = js_hasher.hexdigest()
        css_hash = css_hasher.hexdigest()
    app.app.registry.js_hash = js_hash
    app.app.registry.css_hash = css_hash
コード例 #3
0
ファイル: subscribers.py プロジェクト: vinodpandey/appenlight
def application_created(app):
    webassets_dir = app.app.registry.settings.get("webassets.dir")
    js_hash = generate_random_string()
    css_hash = generate_random_string()
    if webassets_dir:
        js_hasher = hashlib.md5()
        css_hasher = hashlib.md5()
        for root, dirs, files in os.walk(webassets_dir):
            for name in files:
                filename = os.path.join(root, name)
                if name.endswith("css"):
                    with open(filename, "r", encoding="utf8",
                              errors="replace") as f:
                        for line in f:
                            css_hasher.update(line.encode("utf8"))
                elif name.endswith("js"):
                    with open(filename, "r", encoding="utf8",
                              errors="replace") as f:
                        for line in f:
                            js_hasher.update(line.encode("utf8"))
        js_hash = js_hasher.hexdigest()
        css_hash = css_hasher.hexdigest()
    app.app.registry.js_hash = js_hash
    app.app.registry.css_hash = css_hash
コード例 #4
0
ファイル: user.py プロジェクト: vinodpandey/appenlight
def alert_channels_POST(request):
    """
    Creates a new email alert channel for user, sends a validation email
    """
    user = request.user
    form = forms.EmailChannelCreateForm(MultiDict(request.unsafe_json_body),
                                        csrf_context=request)
    if not form.validate():
        return HTTPUnprocessableEntity(body=form.errors_json)

    email = form.email.data.strip()
    channel = EmailAlertChannel()
    channel.channel_name = "email"
    channel.channel_value = email
    security_code = generate_random_string(10)
    channel.channel_json_conf = {"security_code": security_code}
    user.alert_channels.append(channel)

    email_vars = {
        "user": user,
        "email": email,
        "request": request,
        "security_code": security_code,
        "email_title": "AppEnlight :: "
        "Please authorize your email",
    }

    UserService.send_email(
        request,
        recipients=[email],
        variables=email_vars,
        template="/email_templates/authorize_email.jinja2",
    )
    request.session.flash(_("Your alert channel was " "added to the system."))
    request.session.flash(
        _("You need to authorize your email channel, a message was "
          "sent containing necessary information."),
        "warning",
    )
    DBSession.flush()
    channel.get_dict()