Integrating custom view without a model into admin - django-admin

I'm trying to figure out how to integrate a given view into the admin url scheme without manually setting up the url.
Background:
I have three models for which I get data in one CSV file (don't even ask why...). So the import view is not bound to a given model in my concept.
Is there any way to register a view without a model to the default admin site, so that I can add the view to the sidebar block in app_index with an url relative to the app (like "app/import")?
I would like to avoid writing the "admin/app/import" url to my urlconf. However, if that can't be avoided, could someone give me some tips how to at least make them portable? (like variables containing the apps name/base url for the app admin)
I don't know all the magic behind django yet.

Related

SAPUI5 - Header and Footer for all applications

I'm pretty new to SAPUI5 and have a question:
Is it possible to have for example a base application with a custom Header and footer and to change only the content to the view of another application?
So basically I have for example 3 applications and one base application.
In the base application, there is only a page header and footer. I want to change the page content to the first view of one of the three application (for example based on a parameter, passed in URL).
With another parameter passed in URL, The content changes to the view of the second application.
In dynpros it was possible with subscreens, so a new "application" was inserted as a subscreen.
I hope you understand my question.
What you describe, sounds like the Page navivation concept in UI5, using the Router (as #Bernard said). More info here
You can find a more specific example here which does what you describe. You can reuse the code of this example app using the top right corner icon.
A different scenario is the navigation between different apps. In UI5/Fiori an app is the whole package with its own Component.js. So navigating from one app to another app means to load a new Component.js, start the execution from there, and rerender all the application controls, reset the models, and so on so forth. But this should not scare you if you really want to change the whole context. If you configure your apps correctly, you won't need to download the same libraries again when swtching between apps, because they will be cached. So the browser just needs to rerender (miliseconds for a header and footer).

Rails - Store unique data for each open tab/window

I have an application that has different data sets depending on which company the user has currently selected (dropdown box on sidebar currently used to set a session variable).
My client has expressed a desire to have the ability to work on multiple different data sets from a single browser simultaneously. Hence, sessions no longer cut it.
Googling seems to imply get or post data along with every request is the way, which was my first guess. Is there a better/easier/rails way to achieve this?
You have a few options here, but as you point out, the session system won't work for you since it is global across all instances of the same browser.
The standard approach is to add something to the URL that identifies the context in which to execute. This could be as simple as a prefix like /companyx/users instead of /users where you're fetching the company slug and using that as a scope. Generally you do this by having a controller base class that does this work for you, then inherit from that for all other controllers that will be affected the same way.
Another approach is to move the company identifying component from the URL to the host name. This is common amongst software-as-a-service providers because it makes sharding your application much easier. Instead of myapp.com/companyx/users you'd have companyx.myapp.com/users. This has the advantage of preserving the existing URL structure, and when you have large amounts of data, you can partition your app by customer into different databases without a lot of headache.
The answer you found with tagging all the URLs using a GET token or a POST field is not going to work very well. For one, it's messy, and secondly, a site with every link being a POST is very annoying to work with as it makes navigating with the back-button or forcing a reload troublesome. The reason it has seen use is because out of the box PHP and ASP do not have support routes, so people have had to make do.
You can create a temporary database table, or use a key-value database and store all data you need in it. The uniq key can be used as a window id. Furthermore, you have to add this window id to each link. So you can receive the corresponding data for each browser tab out of the database and store it in the session, object,...
If you have an object, lets say #data, you can store it in the database using Marshal.dump and get it back with Marshal.load.

Rails: How to separate static content and application but while maintaining a connection between the 2?

Ok this question might sound a bit weird, let me try to explain what I am trying to achieve here.
I need:
- some mostly static pages: home page, about us, etc. the usual suspects
- a full complex rails web app
The web app being the heart of the system will have a lot of stuff, including user authentication (with devise by the way). The application will have a standard navigation menu with possible actions changing depending on user status (login or not, admin or not, etc).
Until now, nothing out of the ordinary.
However for unrelated reason, I MUST have the entry point of the whole system be the home page that will be hosted on another server (ergh).
So now, since my home page and other static pages will be on server A and all the application will be on server B how can I maintain contact between the 2 ?
Meaning: keep my navigation menu dynamic even on my static pages, have a sign-in / sign-up form on my static server but registering an account on the "real" application server ?
They can share the same database, no pb there.
Any pointers on how to do this ? I would really like not to put some iframes on the static site...
Thanks !
Alex
For the signin/signup stuff, you can have your forms action going to B and redirecting to A.
To display the right stuff in the menus you can make a jsonp call(as Chris said) to fetch either the entire header or specific parts of the header that are dynamic.
If you are just looking to include the users name, you can also simply store their name in a cookie and then use javascript to display it in the header.
If there's no cookie display a link to login/signup.
edit: For the jsonp calls take a look at a javascript framework to make the call client side, I personally use jQuery http://api.jquery.com/jQuery.ajax (and look at the jsonp options).
Thinking out loud...
Can you dynamically build the menus using javascript/AJAX in the static code? Perhaps that could query server B (via jsonp) to determine the options...
Its going to have do some "funky" (tm) stuff to track whether there is a user session or not... and linking them...

Implementing a singleton in Rails

I took over a project and the previous developer used a CMS where the client could enter text and stuff but the problem was that the client wanted some css and javascript and it turned out that this 'about us' page was something that that developer ended up making changes to because the embedded text was full of markup and javascript at the clients request.
I am trying to make it so the client can just input text and it will self format etc... but it's an about us page and I don't want to create resource for this so that is why I'm thinking singleton.
Basically I want the client to have the ability to edit the about us page so it should be attached to the db but it's only one thing. So how would you do this?
Why not just give them a file called about_us.html.erb? They don't have to use ERB in the file. Any time they need to make changes to the file, they can give you a new version and you commit it to your VCS. Or, if you are using something like github.com and they have an account, they can edit the file inline.
You don't even have to have a controller action defined in the controller.

Creating custom content sections with umbraco

I'm working on an umbraco website just now and one of the requirements is to have a custom section in the back end that can be used to manage publish smaller micro-sites.
I have been able to create the new section and added some nodes to it. What I can't get to work is publishing them and making them viewable at the correct url.
As an example, say i have created a new section called microsite, inside that there is a folder called myportfolio. this should route to something like www.myumbracosite.com/microsite/myportfolio.
Does anyone know how to get this sort of thing working? Is it even possible to publish content from outsite of the main content section?
Any help would be greatly apprechiated.
Kind Regards
Colin G
From my understanding the custom sections are for linking to custom databases or data somewhere that needs an interface.
That said, you can use UrlRewriting and an existing content page with a macro to do something like that.
If you had a page called microsite, then using UrlRewriting you could make the parameter passed in to microsite.aspx (a content page in Umbraco) be "myportfolio".
With a user control on the microsite template it could display some content from your external database (or wherever your custom section stores it).
Not sure that's what you're looking for...
Why are you trying to create a new section for more content? The current Umbraco content area has all kinds of permissions for both users and members. Are the microsites all in the same install of Umbraco?
Another option is that the custom section could simply be used as a setup wizard for the new sites. You could create new content and users in their normal places and just use the new section to create them. It's not too hard to create content from C#, so it would probably be the same as doing it from a user control.
Could you provide a little more info?

Resources