Django admin : Expand all the entries in stackedinline by default - django-admin

In my django application, I am using an admin interface to see all the products and each product can have several images. I have stacked the images into the Product Page using the below code
class ProductImage_Inline(admin.StackedInline):
model = ProductImage
extra = 3
formfield_overrides = {
ImageWithThumbnailField : {'widget' : AdminImageWithThumbnailWidget},
By default, in the Product Admin page I can't see all the images because all the entires in the StackedInline are collapsed by default. I have to manually click on each of them to expand so as to see the image.
How can I expand all the entries in a StackedInline by default?
P.S : I am using Grappelli theme and suspect that it is collapsing them by default

I realize that this is a bit late, but, as of Grappelli 2.3.7, you can now easily do what your trying to do with the "inline_classes" attribute of your Inline Class:
class MyInline(StackedInline):
model = MyModel
classes = ('collapse open',)
inline_classes = ('collapse open',)
This didn't seem to work in 2.3.5 (I had to upgrade to 2.3.7 to make it work). And since it isn't clear, 'classes' is the property of the collection of inlines, which can be collapsed or expanded, whereas 'inline_classes' is a property of the inlines themselves.
source: http://readthedocs.org/docs/django-grappelli/en/latest/customization.html#collapsibles

Probably the easiest way to do that is to inject some jQuery code in custom template for that change model.

Related

How to add custom field in Premium items Module in Shopware 5?

I am new in Shopware 5. I want to create custom field in Premium item module.
Please check the screenshot.
I have checked there is no any attribute table for Premium items.
Please tell me how I can create custom field here:
You did not mention what you tried so far, so I will give you some basic information how to start. Feel free to come back with more questions.
Adding the field endPrice to the detail view
The component you want to extend is Shopware.apps.Premium.view.premium.Detail.
You can add your new field, with similar code as the startPrice field.
See the developer guide on backend extensions. This will guide you trough the steps required to extend the detail window. (more information about detail windows is also available)
Extending JS Model / Controller
Basically I recommend to full text search through https://github.com/shopware/shopware/tree/5.7/themes/Backend/ExtJs/backend/premium for startPrice. This will give you a hint what else to extend, to be able to persist your new field endPrice.
Implementing the storage logic
You also need to implement the logic so that the setting actually will be saved. This core code is in Premium.php - there is a special formatting for start-price:
$params['startPrice'] = str_replace(',', '.', $params['startPrice']);
which you might do via a hook.
The basic parameters are stored in s_addon_premiums, but you cannot extend the core model, so you might want to use workarounds as described in another StackOverflow question to store the value of your new endPrice field.
Adding the logic
Finally you can hook into sGetPremiums. You can use an after hook to remove those premium items which should not be added from the returned $premiums array, because the order exceeds the endPrice.

How to develop a schema for the following architecture/ interior design portfolio page?

I am currently developing a portfolio/business page for an architecture/ interior design office. I would like to display index pages for each of the 3 types of projects and would like to categorize images within the project. The idea is to be able to click on each of the pills and display a different set of pics on a carousel on the left(See the image link below). I think I would need a projets model as well as a photo model, but I am not sure if I need a project_type model. Project show page with image carousel on the left and image pills on the right that can change images upon click
From the information that you have provided, I would not create a ProjectType model.
Instead, you can have a PROJECT_TYPES constant. For example:
class Project < ApplicationRecord
PROJECT_TYPES = [:residential, :business, :industrial]
If you decide that you need to store more information that is related to Project Types, then you could create a ProjectType model.

End user can edit the view of a recored in some sort of editor - rails

I'm looking for something like an editor but instead of the user editing just a post or page the user can edit the default template layout or view layout for all pages associated to something.
I'll give an example to get my question across because i really don't know what it would be called.
Say for example you have categories. (people, animals, etc..)
Now imagine there is a category of people, each person in the category has the keys 'height', 'weight' and 'age' and each key has values assigned to them (height: 120 cm, weight: 80 pounds, age: 25)
I want the user to be able to edit the layout of the people page (page template or view that each person is displayed on) and be able to add in the keys they want to be displayed on the page.
So say they add the keys ‘height’ and ‘weight’ it will only display the height and weight on every person page, plus whatever pre set text the user added in the template editor for the people pages to display.
I could probably find a good editor that can be customised and change it to my liking but there might already be gems out there made for this.
My question is, is there a gem for basically letting users set templates for record pages.
Even if there is something out there to change views for objects but the user cant set the keys on it, i'd still like to see it because I might be able to add the key/value functionality to it.
Hopefully you understand what I'm looking for.
UPDATE
Ok so i appears I'm after an editor that works with a template engine like liquid or one thats both an editor and template engine.
If you plan on building from scratch, it sounds like it could be done using rails generate scaffold this allows views/models/controllers to create pages for each of your categories.
Then you can use Associations to create associations between your categories.
You can also make different user roles by making a field called "Role" in your Users relation
Otherwise, there are also open-source software Active Admin to manage content for your categories.
EDIT: After looking around I found a gem you can use to have end-users edit your own views, feel free to check out Liquid.

Automatically populating default issue fields?

We are working on transitioning to Zephyr for JIRA from HP QC/QTP; but a tiny wiggle has presented itself:
When creating a new issue from a test run; the tester has to manually enter version info for the new defect, which on its own is fine, but it's an additional step, and on occasion forgotten.
What we would like then, is for the field "Affects Version/s" to be automatically filled based on either the state of the project, or the sepcific values set in fields in the test.
How can this be achieved?
Allright. You can add custom javascript to JIRA by going to JIRA Administration -> System -> User Interface -> Announcement Banner.
The easiest way is to add a tag linking to your javascript file (wherever it is, must be available to all users. Preferably on the same server as your JIRA installation or a public domain).
Example:
<script type="text/javascript" src="http://YOUR_JIRA_SERVER/includes/custom/javascript/custom.js"></script>
If you add it like above, go into your JIRA installation into the atlassian-jira/includes/ folder and add a folder called custom within which you add another folder called javascript and create a file called custom.js.
In that file, add the following code:
AJS.$(document).ready(function()
{
AJS.$(document.body).on('change', '#issuetype-field', function()
{
var issuetype = AJS.$(this).val();
if(issuetype === "Test") //Might want to change this!
{
AJS.$("#fixVersions").val(17403); //Might want to change this!
}
});
});
This will add an eventlistener to the issuetype-field input found in the create modal window in JIRA. When it changes (which it automatically does on load, then on every user select) it check its value to see if it's Test and if so changes the fixVersion input to a whatever you want to set it to (change this to match your own preferences).
Using jQuery with jira is a bit tricky, you need to use the AJS object to access the jQuery object (more information here: https://docs.atlassian.com/aui/latest/docs/applicationHeader.html).
The two parts you need to change are the actual names and values of your issuetype and your fix version (use firebug or your browsers equivalent to get this).
I've tried this and it worked well! Good luck!

Dynamic embeddedForm

I'm looking to add an embeddedForm dynamically in Symfony 1.4 using Doctrine.
What I'm mainly looking to do is:
1) Only show the relation based on whether or not a checkbox has been ticked
2) If checked, show the embeddedForm
3) Have then the ability to add a new embeddedForm or delete an existing form
I have seen ahDoctrineEasyEmbeddedRelationsPlugin, which looks pretty good with los of configuration. The only problem was that 'newFormsInitialCount'=> 1, means that there is always 1 form as default. I need 0 forms as default and only.
I've also seen a couple of tutorials, but all seem to have at least one relation by default.
For me, the embeddedForm needs to be OPTIONAL, and only display when needed.
Thanks
Follow information based on these links :
http://www.thatsquality.com/articles/stretching-sfform-with-dynamic-elements-ajax-a-love-story
http://www.symfony-project.org/more-with-symfony/1_4/en/06-Advanced-Forms#chapter_06_sub_the_form_saving_process
First is about adding "subforms" with ajax, derived from second you could hide the unneeded form fields and toggle them per javascript (e.g. jQuery.toggle())) !

Resources