Private Web View

Hi all

I am trying to build a site that is only accessible by users with registered account.
They will be able to view announcements posted by administrators.

From my exploration in ERPnext, the only feature that allow this is the web form.

Is there anyone that can point me in the right direction?
Thank you! :slight_smile:

@jlsy check this:

  1. https://github.com/frappe/erpnext/blob/develop/erpnext/templates/pages/order.html
  2. https://github.com/frappe/erpnext/blob/develop/erpnext/templates/pages/order.py

Essentially, you raise frappe.PermissionError when someone unauthorized accesses the page

Thank you so much @anand! :smiley:

@anand, I am facing some issue usring frappe.PermissionError with the web view that is created via Web Generator. The permission error is able to work only once, after i bench restart it. Subsequently, the page is totally public.

Here is my code:

from future import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.website.website_generator import WebsiteGenerator
from frappe.website.render import clear_cache

class Meeting1(WebsiteGenerator):
website = frappe._dict(
template = “www/meeting.html”
)

def validate(self):
self.page_name = self.name.lower()

self.validate_attendees()

@frappe.whitelist(allow_guest=False)
def get_context(self, context):
clear_cache()
check_user = 0

if login_test():

if not context.doc.has_website_permission(“read”):
frappe.throw(_(“Not Permitted”), frappe.PermissionError)
check_user = -1

if (check_user == 0):
context.parents = [{“name”: “meetings”, “title”: “Meetings”}]

add this below template = "www/me...

no_cache=1