Edit the url sent in confirmation email dj_rest_auth - reactjs

When I register a new user the confirmation email sent in the email template contains the url of backend but i need to handle that in forntend. Anyone know how to edit that email template of dj_rest_auth by jazzband?
The email template is:
Hello from example.com!
You're receiving this e-mail because user Pinon has given yours as an
e-mail address to connect their account.
To confirm this is correct, go to
http://localhost:8000/auth/registration/account-confirm-email/Nw:1kO3gI:PQDfxEOyklUYIxpjNN_011ZxGQYPJRdNomzzOFjtXA0/
Thank you from example.com! example.com
But i need it to be like this:
Hello from example.com!
You're receiving this e-mail because user Pinon has given yours as an
e-mail address to connect their account.
To confirm this is correct, go to
http://localhost:3000/account-confirm-email/Nw:1kO3gI:PQDfxEOyklUYIxpjNN_011ZxGQYPJRdNomzzOFjtXA0/
Thank you from example.com! example.com

Ok, this thing is handled by django_allauth package. So you have to do so as they suggested in their (django_allauth) documentation
So I have created my dir like this: templates/account/email/email_confirmation_message.txt then added this code to the file:
{% load account %}{% user_display user as user_display %}{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Hello from {{ site_name }}!
You're receiving this e-mail because user {{ user_display }} has given your e-mail address to register an account on {{ site_domain }}.
To confirm this is correct, Click here.
{% endblocktrans %}
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you from {{ site_name }}!
{{ site_domain }}{% endblocktrans %}
{% endautoescape %}
That
{{ key }}
is the main thing to find 😉.

Related

`first_published_at` not working properly in Wagtail

I have below PageDetail model defined:
class PostDetail(Page):
template = "Post_Detail.html"
body = RichTextField(blank=True)
search_fields = Page.search_fields + [
index.SearchField("body"),
]
content_panels = Page.content_panels + [
FieldPanel("body"),
]
but when I added 2 PageDetail pages (with 15 mins time interval), I found first_published_at was not working properly.
Q1: first_published_at of above 2 newly-added pages are the same Date and Time instead of 15 mins difference.
Q2: Even though I have WAGTAIL_USER_TIME_ZONES = ['Asia/Singapore'] in settings.py of Django Project and restarted the Django server, the first_published_at is still not in correct timezone.
Problem Solved
It turned out to be my silly mistake. In the template file (see below) of Post Index page, problem was fixed after I changed page.first_published_at to post.first_published_at.
{% for post in page.get_children %}
<h2>{{ post.title }}</h2>
<p>{{ post.first_published_at }}</p>
<!-- {{ post.specific.body|richtext }} -->
{% endfor %}
What are your Django settings for timezones? Do you have:
TIME_ZONE = ['Asia/Singapore']
USE_TZ = True
From the docs it looks to me like WAGTAIL_USER_TIME_ZONES is about the admin display parameter rather than what timezone the server is using.
Logged-in users can choose their current time zone for the admin interface in the account settings.

ansible template loop jinja2 "i need a line separated with , but the last entry without ,

i want to create an dynamical playbook for my infrastructure.
i need this line in my config:
wsrep_cluster_address='gcomm://192.168.126.38,192.168.126.39,192.168.126.40'
my template looks like this:
wsrep_cluster_address = 'gcomm://{% for host in groups['db-server']%}{{hostvars[host]['ansible_host']}},{% endfor %}'
it works and looks like this on the host:
wsrep_cluster_address = 'gcomm://172.16.120.45,172.16.120.40,172.16.120.42,'
the last comma is breaking my nerves.
Is there a way to tell ansible not to comma the last entry of the loop?
Tanks for any help, have a great day
Found the solution, thanks to my developer.
wsrep_cluster_address = 'gcomm://{% for host in groups['db-server']%}{{hostvars[host]['ansible_host']}}{% if not loop.last %},{% endif %}{% endfor %}'
You saved my Day!
Also if you need line in config file like JSON:
nodelist = ["192.168.126.38","192.168.126.39","192.168.126.40"]
This is your Ansible for this:
nodelist={%for host in groups['mygroup']%}"{{hostvars[host].ansible_eth0.ipv4.address}}"{% if not loop.last %},{% endif %}{% endfor %}
Here is if full example:
- name: Create List of nodes to be added into Cluster
set_fact: nodelist={%for host in groups['mygroup']%}"{{hostvars[host].ansible_eth0.ipv4.address}}"{% if not loop.last %},{% endif %}{% endfor %}
- debug: msg=[{{nodelist}}]
- name: Set Cluster node list in config file
lineinfile:
path: "/etc/myfonfig.cfg"
line: "hosts: [{{ nodelist }}]"
as results you will have the following line in config file:
hosts: ["192.168.126.38","192.168.126.39","192.168.126.40"]

collections pages loop not working on github

Jekyll Version: 2.4.0
github pages Version: 35
My Reproduction Steps
Build on locally and the looping of collections site.collections.guides.docs shown, generated the correct .html in _site folder as well.
However, when I deploy to github, it doesn't show the loop content.
The Output I Wanted
shown the loop in github pages, appreciate if someone have a look on my repo.
my codes:
// index.html
{% for doc in site.collections.guides.docs %}
{{ doc.content }}
{% endfor %}
// _config.yml
collections :
guides:
output: true
I would write it like this:
{% for doc in site.guides %}
{{ doc.content }}
{% endfor %}
And the config like this:
collections:
guides:
output: true

Symfony2 - Checking if an image type exists

I've been following an earlier post to check if an asset exists, which works great when using specific filenames.
Symfony2 and Twig - Check if an asset exists
However instead of checking for a specific image filename, how do you check for an image type? (all files with the .jpg extension)
Example: *.jpg (which doesn't work neither does .jpg)
{% if asset_exists('/images/*.jpg') %}
<div class="entry-thumbnail">
<img width="230" height="172" src="{{ asset(['images/', post.image]|join) }}" class="" alt=""/>
</div>
{% endif %}
As soon as you are using:
{{ asset(['images/', post.image]|join) }}`
Why not using:
{% if asset_exists(['images/', post.image]|join) %}
Tip: replace ['images/', post.image]|join by using the concat operator ~: 'images/' ~ post.image
You'd have to modify the Twig Extension and replace !is_file($toCheck) with count(glob($toCheck)) < 1
glob function (php.net)

Can I create an runtime-array with values somehow?

I am trying to create a sidebar-menu that looks like this.
iOS
-entry1
-entry2
-entry3
Web
-entry1
-entry2
Other
-entry1
-entry2
Each "post" (as in - the files in the dir "_posts") will have one (or more) categories in the meta-data (at the top of the file) and is to be listed underneath that header in the menu. So for example, if I make a post which has got "categories: iOS" it should be listed under the "iOS" header in the menu.
{% for cat in ["jekyll","ios","test"] %} // This is what I am unable to get right
{% for post in site.posts %}
{% if post.category == cat %}
{{ post.categories }} // test
<li>{{ post.title }}</li>
{% endif %}
{% endfor %}
{% endfor %}
Is it not possible to create an array on the fly like this? I am finding it really hard to google this specific question I have.
Alright to create an array on the current page I needed to use "front matter" i.e. the things on top of the pages surrounded by "---"
This is the solution:
Top of page:
---
cats: [1,2,3,asd]
---
Further down:
{% for c in page.cats %}
{{c}}<br/>
#loop through more here.
{% endfor %}
</body>

Resources