Wagtail Admin UI: create HomePage without a Site leads to AttributeError crash - wagtail

I'm new to Wagtail, and I'm exploring the Bakery demo [that is a great demo, by the way!]. I can produce an AttributeError, 'NoneType' has no attribute 'startswith'".
The problem is that the Preview code in the Admin UI assumes that there is a site for every Page. But in my case there is no site yet.
I got to this point by not paying enough attention to the warnings in the Admin UI. But still, a little defensive programming in the Wagtail admin code will protect against this error.
Steps to reproduce:
Get the Bakery demo up and running.
Wonder about creating my own site, as a sibling of the Bakery site. Note the absence of a 'Sites' entry in the Admin UI sidebar, and decide to create a new HomePage thing via Pages -> Add child page (to Root) -> select HomePage as the type of the new child of Root.
Read this warning, but pay no attention: "These is no site set up for this location. Pages created here will not accessible at any URL until a site is associated with this location. Create a site now"
Create a new HomePage thing.
Click "Preview".
Uh-oh.
The problem is that the Preview code in the Admin UI assumes that there is a site. But in my case there is no site yet.
It seems to me that the code that does the Preview operation can check in advance for an associated Site. Or perhaps the code can catch the AttributeError and compose an error response of its own.

Moved to github, as suggested by gasman. I apologize - I misread the wagtail.io website about where to get support.

Related

How do I find out where a Visualforce page is being used in my Salesforce org?

I am fixing soql injection errors in my Salesforce org. How do I find out where that page is being called from in Salesforce? I tried looking at the 'Where is this used?" button under setup/Visualforce page/edit/ and it just shows me the test that it is being called from. I checked the show dependencies and it shows me the controller that it is associated with. I can't seem to figure how I can access the page in Salesforce so I can do a manual test on it.
Create a sandbox and try to delete it in there. If page is "properly" used - dependency should block the delete. Can be custom VF tab, button, link, embed on page layout as iframe... Can even be in community or Site as a login page for example.
If you have the project in git or sfdx you could try searching for page's API name.
But pages can be also accessed freestyle, in classic UI you used to just /apex/vfpagename in the address bar. In lightning it's bit more complex but doable for a determined user.
If you want to block access while you fix it - remove right to use the page from profiles / permission sets.
https://salesforce.stackexchange.com/a/12672/799
https://lightning-configuration.salesforce.com used to give some info about VF pages usage (count of hits I think) and there's whole Event Monitoring module paid extra (standalone or as part of Salesforce Shield) too

2sxc "had an Error Talking with the Server (Status 403)"

I installed a 2sxc version 11.11.3 Inside a fresh dnn 9.3.2.
After this I created a content Module with the simple test view inside. After this I granted this module the edit permission to the Registered Users Group on dnn module Level.
If I log in as a registered user I can see the 2sxc toolbar (blue symbols when hovering the item of the module) of the Module and the items. If I press the edit icon I get the Message "had an Error Talking with the Server (Status 403)".
Has anyone an idea what I am doing wrong?
Thank you very much
Robert
Edit1
The browser console shows following content in the ERROR object:
error: "Permission denied. required permissions for this request are not given"
headers: t
lazyInit: ƒ ()
lazyUpdate: null
normalizedNames: Map(0) {}
__proto__: Object
message: "Http failure response for https://.../api/2sxc/cms/edit/load?appId=2: 403 OK"
name: "HttpErrorResponse"
ok: false
status: 403
statusText: "OK"
url: "https://.../api/2sxc/cms/edit/load?appId=2"
Edit2
After this I wanted to explore, if the behavior is 2sxc Content module related or if it is related to all apps (in my understanding the 2sxc Content module is an app too). I installed the "FAQ" app, granted the dnn "Edit" permission to the "Registered users" group and logged in as a registered user and pressed the edit icon on the 2scx toolbar - and had the same behavior like described in the origin post.
But: I got it running for the "FAQ" app, but not for the "Content" app. Here are my steps to get it running for the "FAQ" app:
click on "Apps management" (available in the dnn edit action or in the 2sxc toolbar)
"Features" - add feature - enable "Permission by Group / Role" - Activate feature
"Apps" - "FAQ" (or another except Content)
"App" - "App Permissions" (click on the icon) - "create new permission" - Identity=xx (xx=RoleId of the Group in table dbo.Roles) - Grant=Edit (in my case I want that the current registered user is able to edit an item) - Save (Ctrl+S)
After this I was able to edit the item of the "FAQ" module.
The "App Permissions" icon is disabled by default for the "Content" module on App level (and on view and data level too). Does anyone know if this is by design or is there a possibility to activate this option? Otherwise I have to migrate my content views to an app to get the permissions running.
Edit3
I ended up by migrating the content of the "Content" app to a new custom app. The effort is very less and getting the possibility to grant permissions was worth doing it.
In a conclusion I'll answer my question by myself. I suppose that the "Content" app has not the possibility granting the dedicated permissions. But the app itself has the posibility - so it could be a good idea, to create content inside an app.
Just some background: The content-app is meant for simple content and behaves differently from normal apps. Example:
when you add a content-app, the dialog asks for you to choose what content-type, and what view
when you add an app, the dialog asks you for which app, and then what view
Basically the content-app has various optimizations to make it lighter and simpler, but we wanted to prevent people from "shooting themselves in the foot" because they will usually start with content, and then make it increasingly complex (never separating different concerns) and end up with a big mess.
This is why the content-app has some forced limitations (like no app-permissions) to guide people to place more complex functionality in own apps.
Now note that this doesn't explain your original issue: apparently edit-permissions didn't work as expected. That seems to be a bug, not an intension. If you think that should be followed up, best create an issue on github.

Can't edit certain pages on DNN site after upgrade to 9.01.01

We recently upgraded one of our client sites to 09.01.01 to address a Telerik vulnerability, and then had to migrate the site from managed.com to Azure due to manage.com's outage. After the upgrade, a couple of pages on the site have been uneditable using the pencil icon in the persona bar, although the rest work fine. We're aware of the workaround of going into content > pages and clicking the pencil icon there, but even then not all of the areas on the page are editable. For example, there's one instance of the HTML module on the homepage where when you click on its pencil and then click "Edit Content," it just displays a pop-up with the text but no WYSIWYG or way to actually edit. Other instances of the HTML module work fine, on other pages and even other areas of the homepage.
What's more bizarre is that we just spun up another Azure VM and created a dev site from a clone of the live site so we could troubleshoot further, and this problem does NOT occur on that site even though it's an exact copy of the live site files and database and both sites are hosted in Azure.
Does anyone have advice on what might be causing this or how to troubleshoot? My original though was to clone the page and start removing modules one by one to see if anything made a difference, but it doesn't actually remove the module when I click delete. I've read about ways to do this directly in the database, but I'd prefer to avoid that if possible, especially since we're not seeing the same problem on the cloned site.
Thank you!
Could you please see if any error appearing on the logs folder? You can see the logs here. /Portals/_default/logs/2021.02.01.log.resources? The log file name may differ based on website's logging configuration.
A similar thing can be seen from the Personal bar as well using Admin Logs.

Wagtail: How to use wagtailuserbar for moderation (approving and rejecting draft posts)

We are using the wagtailuserbar templatetag on our site and it works fine for published pages. We get the "Edit this page" and "View in admin" options etc.
The documentation says that wagtailuserbar can also be used by moderators to approve/reject drafts but I can't get this work.
Quote from the documentation:
Moderators are also given the ability to accept or reject a page being previewed as part of content moderation.
This screenshot shows the admin website with a page that has been submitted for moderation:
Clicking the preview link opens a new tab but the wagtail userbar is not visible.
If one instead uses the View Draft feature in the page explorer then again, new tab but no userbar.
Looking at the source code here these lines seem to remove the userbar for any preview view:
# Don't render if this is a preview. Since some routes can render the userbar without going through Page.serve(),
# request.is_preview might not be defined.
if getattr(request, 'is_preview', False):
return ''
My question is:
How can I use the wagtail userbar to approve or reject previews of pages submitted for moderation? The documentation suggests this is possible but experience and my understanding of the code suggests not.
It's a feature I'd really love to use.
Thanks for any help.
Thanks for this very clear description of the problem. I think this is a bug, which I've raised here:
https://github.com/wagtail/wagtail/issues/6008

CMS user cannot see "add child page" button

I am trying to use Wagtail within a pre-existing Django project. I have installed the CMS, and it seems to be working well within the existing Django admin - I can authenticate using one of Django admin's users and see the CMS UI, all good.
But: No matter what I try, as an admin user, I cannot see the "Add Child Page" button at the URL of the page e.g /cms/pages/3/. The "Add Child Page" lozenge icon does not show. This is a bit of a pain, because all tutorials and examples assume that this icon is already showing!
The user I am logged-in as is set as "is_superuser" = 't' in auth_user, and one of the two groups the user is in, has been granted ALL wagtail permissions within Django admin (I was desperate!), but still no dice. I've also tried giving ALL perms to other (non-admin) users, and logging-in as them, but still cannot see the button.
I have created a basic HomePage that subclasses Page and I still see no way to create one. delving deeper, I see that one of the user's groups (auth_group.id=1) has the "add" permission in "wagtailcore_grouppagepermission" for the page I am viewing in the CMS which appears correct.
I am new to Python/Django, so I may have missed something obvious!
Django 2.2
Wagtail 2.8.1
CentOS
Python 3.6
(Docker multi-service setup through docker-compose using CentOS)
[UPDATE]
I can see that the following line is failing the test for specific_class being anything other than None. If I hack the line to return True, I see the button in the CMS UI:
./core/models.py:
def can_add_subpage(self):
...
if specific_class is None or not specific_class.creatable_subpage_models():
print('##', specific_class) # None
return False
...
Why would specific_class be None? What exactly is specific_class?
Take a look at the subpage_types declaration: https://docs.wagtail.io/en/latest/reference/pages/model_reference.html?highlight=parent_page#wagtail.core.models.Page.subpage_types
Also see parent_page_types below that.

Resources