Register a site-setting-like to appear under custom Wagtail sidebar menu - django-admin

I have created a custom menu section for my Wagtail models (Major and Minor) using wagtail_hooks. They appear fine under a custom ModelAdminGroup:
── Wagtail
├── Pages
├── Images
├── Documents
├── Snippets
├── Shops
│ ├── Major
│ └── Minor
│ └── ...
├── .
├── .
├── .
└── Settings
Now, I have some details around shops that needs to be store more like a setting field and not in a Page model. The common way of doing this is to register this new feature (Shop Contacts) in settings by using the register_setting decorator. This will result in Shop Contacts appearing under Settings.
However, what I want to achieve is to move it under Shops so it looks something like this:
── Wagtail
├── Pages
├── Images
├── Documents
├── Snippets
├── Shops
│ ├── Major
│ └── Minor
│ └── ...
│ └── Shop Contacts
├── .
├── .
├── .
└── Settings

What you are asking to do is pretty similar to the LibraryGroup example in https://docs.wagtail.org/en/stable/reference/contrib/modeladmin/index.html#a-more-complicated-example

Related

How to write files in an iOS app to make them visible to afc protocol?

I am writing an iOS app, and I wish to be able to copy data directly from the iOS device using a laptop.
A good example I found is Wikipedia's official iOS app (https://apps.apple.com/app/wikipedia/id324715238?mt=8). After I downloaded this app and used it for a while, I see a directory structure built in afc://.../org.wikimedia.wikipedia if I connect my device to a laptop running Linux. The structure is like below:
├── assets
│   ├── about.html
│   ├── abusefilter.css
│   ├── abusefilter.html
│   ├── bundle.js
│   ├── footer.css
│   ├── index.html
│   ├── index.js
│   ├── ios.json
│   ├── languages.json
│   ├── mainpages.json
│   ├── preview.css
│   ├── preview.html
│   ├── preview.js
│   ├── styleoverrides.css
│   ├── styles.css
│   └── Wikimedia-logo.png
├── piwiktracker
├── piwiktracker-shm
├── piwiktracker-wal
├── WikipediaYap.sqlite
├── WikipediaYap.sqlite-shm
├── WikipediaYap.sqlite-wal
└── WMFHomeSections.plist
However, I am not able to find some official documents or tutorials, that teach me how to write a Swift program that accesses or modifies this directory. What I want to do is basically opening a text file and write some lines into it. Any help will be appreciated.
It seems that what I am trying to find is the Documents directory in my iOS app's sandbox directory (from documentation).
The directory can be made visible in afc protocol by following this answer,
and this answer gives a good example of writing to a file in that directory.

How do I import a locally created package in Dart?

Say my projects' structures are as follows.
contact_book <---(App)
   ├── bin
   │   └── contact_book.dart
   ├── contact_book.iml
   ├── lib
   │   ├── address.dart
   │   ├── email.dart
   │   ├── field.dart
   │   ├── functions.dart
   │   ├── person.dart
   │   └── phone_number.dart
   ├── pubspec.lock
   └── pubspec.yaml
functions <---(Package)
├── bin
│   └── lib
│   └── functions.dart
├── functions.iml
├── pubspec.lock
└── pubspec.yaml
Both folders are in the same directory. How do I call a function that's part of a .dart file that's in my other package? From reading the dart website, it seems like it's possible. That way I can write my own functions and use them across different projects. Did I just read that wrong and have to copy the files into my program?
Link: Create Library Packages - Dart
See https://www.dartlang.org/tools/pub/dependencies under "Path Packages". You need only one copy, but you might need to "pub upgrade" whenever you change the included path.
Edit: "You don’t need to run pub every time you change the dependent package." And now I know!
To use the local package "functions", which is located in the same directory as the project "contact_book", add the following code to the file "contact_book/pubspec.yaml":
dependencies:
functions:
path: ../functions

Xcode iOS appicon assets drag and drop - am I doing this wrong?

I am curious if I am doing this wrong or is this really this much work to place the icons for different sizes?
I have the app icons for my app with following names:
├── iPad
│   ├── Icon-76.png
│   ├── Icon-76#2x.png
│   ├── Icon-83.5#2x.png
│   ├── Icon-Small-40.png
│   ├── Icon-Small-40#2x.png
│   ├── Icon-Small.png
│   └── Icon-Small#2x.png
├── iPhone
│   ├── Icon-60#2x.png
│   ├── Icon-60#3x.png
│   ├── Icon-Small-40#2x.png
│   ├── Icon-Small-40#3x.png
│   ├── Icon-Small#2x.png
│   └── Icon-Small#3x.png
└── iTunes\ Artwork
├── iTunesArtwork
└── iTunesArtwork#2x
as you notice all of them have been named correctly and have the #2x or #3x respectively.
Now the way I place the icons in xcode is to manually drag and drop all 13 of the icons one by one. Is this really the right way? Any better way to do all at once?
I have to change the icons often while development and design and this seems a lot of work.

redmine adding subview to project page

I have created plugin for redmine that displays issues with some additional info.
Plugin works ok.
Now i want this information to be shown on project page under issues summary.
ive read this article
http://www.redmine.org/boards/3/topics/33949
and rednder_on approach looks very promising.
ive added new plugin with hook for view_projects_show_right
code looks like this
# lib/release_history_hook.rb
class ReleaseHistoryHook < Redmine::Hook::ViewListener
render_on :view_projects_show_right, :partial => 'bottlenecks/view_issues'
end
bottlenecks plugin tree structure is like this
/opt/redmine/plugins/bottlenecks/
├── app
│ ├── controllers
│ │ ├── bottlenecks_controller.rb
│ │ └── bottlenecks_controller.rb~
│ ├── helpers
│ │ ├── bottlenecks_helper.rb
│ │ └── bottlenecks_helper.rb~
│ ├── models
│ └── views
│ └── bottlenecks
│ ├── view_issues.html.erb
│ ├── view_issues.html.erb~
│ ├── view_issues.html_original.erb
│ ├── view_issues.html_original.erb~
│ └── view_users.html.erb
├── assets
│ ├── images
│ ├── javascripts
│ └── stylesheets
├── config
│ ├── locales
│ │ └── en.yml
│ └── routes.rb
├── db
│ └── migrate
├── init.rb
├── init.rb~
├── lib
│ └── tasks
├── README.rdoc
└── test
├── fixtures
├── functional
│ └── bottlenecks_controller_test.rb
├── integration
├── test_helper.rb
└── unit
21 directories, 16 files
Ive tried to specify full path,path with extensions ...all the combinations.
When i run redmine and access project page its always gives me 404 error.
I clearly misunderstand something very basic.
I just cant find more information on that subject.
What am i doing wrong?
Also render_on seems to be deprecated. What can i use instead?
it seems to me that you named your partial incorectly without prefix "_".
You should place file _view_issues.html.erb to YOUR_PLUGIN/app/views/bottlenecks/
Source to read more
http://www.redmine.org/projects/redmine/wiki/Hooks
Examples:
how to call hook https://github.com/edavis10/redmine_contracts/blob/master/lib/redmine_contracts/hooks/view_issues_show_details_bottom_hook.rb
code of the hook https://github.com/edavis10/redmine_contracts/blob/master/app/views/issues/_show_deliverable.html.erb

Why does `pub install` keep creating `packages` link in all the subdirs of `web`?

I have a web dir, which contains some css and js files:
├── bootstrap-wysiwyg
│   ├── index.html
│   ├── packages -> ../../packages
│   └── republish.sh
├── css
│   ├── bootstrap-combined.no-icons.min.css
│   ├── packages -> ../../packages
│   ├── prettify.css
│   └── screen.css
├── images
│   └── packages -> ../../packages
├── js
│   ├── bootstrap.min.js
│   ├── packages -> ../../packages
│   ├── prettify.js
│   └── prettify.js.1
├── lib
│   ├── font-awesome-3.2.1
│ └── packages -> ../../packages
└── packages -> ../packages
You can see there are one packages link in each subdir of the web dir. I deleted them once, but it will appear when I run pub install.
I can't understand why pub will create them for me, and is there any way to disable it? I don't want them because when I run build command in my IDEA Dart-plugin, it will reports errors since it can't handle them correctly.
When Dart sees an import like:
import 'package:foo/foo.dart';
It translates it to:
import '<url of your entrypoint>/packages/foo/foo.dart';
So, say your app's entrypoint is in:
myapp/web/app/main.dart
If it has a "package:" import, like above, it will remap it to:
import 'myapp/web/app/packages/foo/foo.dart';
That means that for Dart to be able to find foo.dart, there needs to be a packages directory inside app that contains foo/foo.dart. Part of pub's job is to set that up for you.
This is definitely not the nicest part of working with Dart and pub. Spewing symlinks everywhere is gross, but it deals with the limitations that the language places on us. Over time, we're hoping to move away from having to create these symlinks.
More details on this here.

Resources