<%inherit file="/user/settings.html" />
<%namespace name="forms" file="/forms.html"/>
<%namespace name="components" file="/components.html"/>


<%block name="settings_content">
${tiles.user.header(c.page_user)}
<form class="well" method="POST" enctype="multipart/form-data">

    <input type="hidden" name="_method" value="PUT" />

    ${h.field_token()|n}

    ${components.flashmessages()}

    <h2>${_(u'Notification settings')}</h2>

    <p class="info">
      ${_("Select how you would like to be notified of events.")}
    </p>

    ${forms.input(_("Email"), 'email')}

    %if c.page_user.email is not None:
    %if c.page_user.is_email_activated():
    <fieldset>
        <p class="help-block">${_('Please select on which occasions you would like to receive an email. The options further down this list will allow you to receive email notifications for all the above points too.')}</p>
        <ul class="nobullet">
            <li><label>
                <input type="radio" name="email_priority" value="6"
                       ${"checked='checked'" if c.page_user.email_priority==6 else ""} />
                ${_('No notifications via email.')}
            </label></li>
            %if h.has_permission("watch.instance"):
            <li><label>
                <input type="radio" name="email_priority" value="5"
                       ${"checked='checked'" if c.page_user.email_priority==5 else ""} />
                ${_('Send email for new proposals or norms in my watched instances')}
            </label></li>
            <li><label>
                <input type="radio" name="email_priority" value="4"
                       ${"checked='checked'" if c.page_user.email_priority==4 else ""} />
                &hellip;${_('and when a watched object is edited or deleted')}
            </label></li>
            %else:
            <li><label>
                <input type="radio" name="email_priority" value="4"
                       ${"checked='checked'" if c.page_user.email_priority==4 else ""} />
                ${_('Send email when a watched object is edited or deleted')}
            </label></li>
            %endif
            <li><label>
                <input type="radio" name="email_priority" value="3"
                       ${"checked='checked'" if c.page_user.email_priority==3 else ""} />
                &hellip;${_('and when a watched object is commented on')}
            </label></li>
            <li><label>
                <input type="radio" name="email_priority" value="2"
                       ${"checked='checked'" if c.page_user.email_priority==2 else ""} />
                &hellip;${_('and when a watched object is rated')}
            </label></li>
            %if h.has_permission("watch.instance"):
            <li><label>
                <input type="radio" name="email_priority" value="1"
                       ${"checked='checked'" if c.page_user.email_priority==1 else ""} />
                &hellip;${_('and when new members join my watched instances')}
            </label></li>
            %endif
        </ul>
    </fieldset>
    %else:
    <div>${_("Not confirmed.")}
        <a href="/user/${c.page_user.user_name}/resend?${h.url_token()}">${_("Re-send activation link")}</a>
    </div>
    %endif
    %endif

    <br />

    ${forms.checkbox(_("Receive messages via email"), 'email_messages',
                     help=_(u"Receive messages from administrators and other users via email. (These messages are always available on your dashboard)"))}

    ${components.savebox(cancel_url=None)}

</form>
</%block>
