fix: patch to update name of member

This commit is contained in:
pateljannat
2021-04-12 18:05:43 +05:30
parent 0e1002392f
commit d38c64650e
8 changed files with 43 additions and 47 deletions

View File

@@ -2,7 +2,6 @@
"actions": [],
"allow_guest_to_view": 1,
"allow_rename": 1,
"autoname": "field:email",
"creation": "2021-02-12 15:47:23.591567",
"doctype": "DocType",
"editable_grid": 1,
@@ -108,7 +107,7 @@
"has_web_view": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-04-12 13:34:41.573486",
"modified": "2021-04-12 17:32:36.211603",
"modified_by": "Administrator",
"module": "Community",
"name": "Community Member",

View File

@@ -27,10 +27,6 @@ class CommunityMember(WebsiteGenerator):
frappe.throw(_("Username can only contain alphabets, numbers and underscore."))
self.username = self.username.lower()
def on_update(self):
if self.username != self.name:
rename_doc(self.doctype, self.name, self.username, force=False, merge=False, ignore_permissions=True, ignore_if_exists=False)
def create_member_from_user(doc, method):
member = frappe.get_doc({
"doctype": "Community Member",

View File

@@ -149,6 +149,8 @@ whitelist = [
"/sketches",
"/admin",
"/socket.io",
"/hackathons",
"/dashboard"
]
whitelist_rules = [{"from_route": p, "to_route": p[1:]} for p in whitelist]

View File

@@ -1 +1,2 @@
community.patches.set_email_preferences
community.patches.set_email_preferences
community.patches.change_name_for_community_members

View File

@@ -0,0 +1,12 @@
from __future__ import unicode_literals
import frappe
from frappe.model.naming import make_autoname
from frappe.model.rename_doc import rename_doc
def execute():
frappe.reload_doc("community", "doctype", "community_member")
docs = frappe.get_all("Community Member")
for doc in docs:
member = frappe.get_doc("Community Member", doc.name)
name = make_autoname("hash", "Community Member")
rename_doc("Community Member", member.name, name, force=True, merge=False, ignore_permissions=True, ignore_if_exists=False)

View File

@@ -1,4 +1,5 @@
{% extends "templates/base.html" %}
{% from "www/macros/profile.html" import profile %}
{% block title %}{{ _("Community") }}{% endblock %}
{% block head_include %}
<meta name="description" content="{{ 'Community' }}" />
@@ -86,19 +87,6 @@
</style>
{% endblock %}
{% macro profile(photo, full_name, abbr, icon) %}
{% if photo %}
<img class="avatar rounded-circle img-fluid mr-5{% if icon == 'large' %} avatar-xl {% else %} avatar-large {% endif %}"
src="{{ photo }}" alt="{{ full_name }}">
{% else %}
<div class="col-sm-2">
<div class="standard-image {% if icon == 'large' %} dashboard__abbr {% else %} dashboard__abbrSmall {% endif %}">
{{ abbr }}
</div>
</div>
{% endif %}
{% endmacro %}
{% block content %}
<section>
<div class="dashboard__parent">
@@ -159,9 +147,9 @@
<div class="tab-pane fade py-4" role="tabpanel" id="sketches">
<div class='container'>
<a href="/sketches/new">Create a New Sketch</a>
{% if sketches %}
{% for sketch in sketches %}
<div class="row row-cols-1 row-cols-xl-5 row-cols-lg-4 row-cols-md-3 row-cols-sm-2 pt-5">
<div class="row row-cols-1 row-cols-xl-5 row-cols-lg-4 row-cols-md-3 row-cols-sm-2">
{% if sketches %}
{% for sketch in sketches %}
<div class="col mb-4">
<div class="card sketch-card" style="width: 200px;">
<div class="card-img-top">
@@ -179,11 +167,11 @@
</div>
</div>
</div>
{% endfor %}
{% else %}
<p class="text-center">You have not created any sketches.</p>
{% endif %}
</div>
{% endfor %}
{% else %}
<p class="text-center">You have not created any sketches.</p>
{% endif %}
</div>
</div>
<div class="tab-pane fade py-4" role="tabpanel" id="courses">

View File

@@ -0,0 +1,12 @@
{% macro profile(photo, full_name, abbr, icon) %}
{% if photo %}
<img class="avatar rounded-circle img-fluid mr-5{% if icon == 'large' %} avatar-xl {% else %} avatar-large {% endif %}"
src="{{ photo }}" alt="{{ full_name }}">
{% else %}
<div class="col-sm-2">
<div class="standard-image {% if icon == 'large' %} dashboard__abbr {% else %} dashboard__abbrSmall {% endif %}">
{{ abbr }}
</div>
</div>
{% endif %}
{% endmacro %}

View File

@@ -1,25 +1,11 @@
{% extends "templates/web.html" %}
{% from "www/macros/profile.html" import profile %}
{% block page_content %}
<div class="py-20 row">
{% if user.photo %}
<div class="col-sm-2 border border-dark">
<img src="{{ user.photo }}" alt="{{ user.full_name }}">
<section>
<div>
{{ profile(member.photo, member.full_name, abbr, "large")}}
</div>
{% else %}
<div class="col-sm-2">
<div class="standard-image" style="font-size: 30px;">{{ user.abbr }}</div>
</div>
{% endif %}
<div class="col">
<h1>{{ user.full_name }}</h1>
{% if user.short_intro %}
<p class="lead"> {{ user.short_intro }} </p>
{% endif %}
{% if user.bio %}
<p class="markdown-style"> {{ frappe.utils.md_to_html(user.bio) }} </p>
{% endif %}
</div>
</div>
</section>
{% endblock %}
<!-- this is a sample default web page template -->
<!-- this is a sample default web page template -->