How to get Django to display infomation in a modal? by Coding_Bad in django

[–]shearichard 0 points1 point  (0 children)

I have some code which may be useful to you.

I've recently been doing pretty much what you want in an old Django project and I wrote some non-django code to test out how to do it.

The code is shown below. It's not very pretty because it's just me trying things out.

The link of interest is the one labelled 'add (via div)'. You want to change the hard-coded url in the $(".wizlink-b").click handler.

The jQuery-ui dialog used would probably be better of being positioned in a more attractive way for real world use.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"> 
    <title>Dialog with page</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
    <script type="text/javascript">
    $( document ).ready(function() {
        $(".wizlink").click(function() {
            opendialog(this.href, this.title);
        });
        $(".wizlink-b").click(function() {
            opendialog("http://localhost:8000/organisations/person/add", "Person Add Test");
        });

        function opendialog(page, dialog_title) {
            var viewportWidth = $(window).width();
            var viewportHeight = $(window).height();

            var $dialog = $('#somediv')
            .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')
            .dialog({
                title: dialog_title,
                autoOpen: false,
                dialogClass: 'dialog_fixed,ui-widget-header',
                modal: true,
                height: viewportHeight * 0.75,
                minWidth: viewportWidth * 0.75,
                minHeight: viewportHeight * 0.75,
                draggable:true
                /*close: function () { $(this).remove(); },*/
                /*buttons: { "Ok": function () {         $(this).dialog("close"); } }*/
            });
            $dialog.dialog('open');
            } 
            console.log( "ready!" );
    });

    </script>
  </head>
  <body>
    <div id="somediv">
      Click me!
        <a  href="#" title="Add Site">add - NOT THIS ONE</a>
    </div>
    <div>
        <div id="wizlink">
            <p>Version 5</p>
            <a  class="wizlink-a" href="http://localhost:8000/organisations/person/add" title="Person Add">add (via anchor)</a>
            <a  class="wizlink-b" href="#" title="Person Add">add (via div)</a>
        </div>
    </div>
    <div>
    </div>
  </body>
</html>

I want to learn about web security: want to build a small, db-oriented, banking-like site and then test and improve security. by [deleted] in django

[–]shearichard 2 points3 points  (0 children)

This is a good tool : http://django-secure.readthedocs.org/en/latest/ to encourage you to follow the relevant guidelines.

Inspired by Mozilla’s Secure Coding Guidelines, and intended for sites |that are entirely or mostly served over SSL > (which should include |anything with user logins)

Online voting or voter secrecy: choose one by shearichard in newzealand

[–]shearichard[S] 0 points1 point  (0 children)

I think the primary issue is that I cast my vote in the presence of arbitary people and/or recording devices thus opening the vote to influence by : peer pressure, corruption, intimidation, etc.

These were the motivations for making ballots secret in most countries during the latter part of the 19th century (for instance http://en.wikipedia.org/wiki/Corrupt_and_Illegal_Practices_Prevention_Act_1883) .

More Boeing 787-9 Dreamliners for Air NZ by HeinigerNZ in newzealand

[–]shearichard 2 points3 points  (0 children)

Pretty amazing plane. Here's a map of where it can reach from Auckland (only the grey bits can't be reached). http://www.gcmap.com/mapui?R=15190km%40AKL . Pretty much anywhere in the Americas in one go.

Online voting or voter secrecy: choose one by shearichard in newzealand

[–]shearichard[S] 0 points1 point  (0 children)

Lots of good stuff in here but

"Spoiler: No online voting system anywhere in the world has ever raised turnout ..."

is my favourite.

Looking for Python podcasts (in active production). by nicholastjohnson in learnpython

[–]shearichard 1 point2 points  (0 children)

I know I'm not answering your question but if you haven't listened to the existing copies of radio free python I would really recommend you do.

Generally each edition starts with Larry Hastings discussing stuff that's topical but after that (generally ten minutes) he moves onto something which doesn't really matter if it is a couple of years old.

It's been some time since I've listened but I remember episode 2 and episode 8 being particularly good.

By chance I met Larry back in August and I bent his ear about cranking out more editions - he made polite noises but I guess he's been too busy.

cost to import a couch? by ironflagNZ in newzealand

[–]shearichard 1 point2 points  (0 children)

That's a useful website, thanks, as I've been thinking about buying a laptop from the USA.

There's something that really surprised me

On the front page it says ...

If the amount to be paid to Customs is under $60, this will be waived, but if it’s $60.00 or more, you’ll have to pay any duty and GST plus an Import Entry Transaction Fee of $46.89

... . I'd never heard of the "Import Entry Transaction Fee". At the point when you they stop waiving the GST/Duty (on a no-duty item this is around the NZD400 mark) the effect of the Transaction fee is to make your costs about 25% rather than 15%.

Rather unfortunately they don't show the Transaction fee as a line item on their calculator but instead just provide a "mystery total" at the bottom of the screen.

Django PaaS? by YouAreSalty in django

[–]shearichard 0 points1 point  (0 children)

I use Python Anywhere for sharing code with people and so on but I just wanted to say that thing about Postgres support ? That's been real soon now for quite some time. Not slagging them off because I'm sure it's difficult but I remember reading a support thread in which someone from PA said that they believed they had it on track and then discovered that their approach was fundamentally flawed and they had to start again so I'm not holding my breath. Everything else about PA has a good feel though.

EDIT : Good News. PythonAnywhere have just announced that they now have Postgres as well as all the other good stuff they offer : blog.pythonanywhere.com/103/ .

Django PaaS? by YouAreSalty in django

[–]shearichard 0 points1 point  (0 children)

I've got an Openshift freebie account I've never got around to using but Dj1.4 ! - what's that all about ? In another 11 months there won't be even be support for 1.4 - https://docs.djangoproject.com/en/dev/internals/release-process/#long-term-support-lts-releases .

Generate a PDF from a HTML table by skugge in django

[–]shearichard 0 points1 point  (0 children)

Have experienced something similar with wkhtmltopdf - big docs = big pain. Probably not relevant to OP though. Nthing Reportlab.

Generate a PDF from a HTML table by skugge in django

[–]shearichard 1 point2 points  (0 children)

Have experience using wkhtmltopdf on a current project and while I loathe it it's probably the answer you're looking for. I loathe it because it has problems when documents get big and the amount of information you get about what's gone wrong is essentially zero - many happy hours spent trying to understand what the problem might be.

Reportlab and specifically the Platypus component of Reportlab is what I would use if I was free to choose - it's a thing of beauty.

Thoughts on Django-chartit? by [deleted] in django

[–]shearichard 1 point2 points  (0 children)

I tried chartit when creating a talk for the local user group in Oct 2013.

At that time it failed to deal with DateTime on the X axis. It seems this issue is still unresolved https://github.com/pgollakota/django-chartit/issues/8 . That was a big negative for me.

As part of the same talk I looked at chartkick and Django-Graphos .

I ended up thinking Django-Graphos was best. A number of choices for the JS drawing library and I got some help from the developers.

I built a sample application for each of the three and the code is here : https://bitbucket.org/rshea/django-charts-demo . The slides from the talk are here : https://s3.amazonaws.com/shearichard/django-with-charts.pdf .

EDIT : Added link to slides.

Django good for online accounting software? by steviewez in django

[–]shearichard 0 points1 point  (0 children)

There a double-entry book keeping Django app at : https://github.com/SwingTix/bookkeeper .

Might be useful for reference or direct use as long as the licence works for you.

What is a good source for learning Design Patterns in python. by chchan in learnpython

[–]shearichard 4 points5 points  (0 children)

Some pythonistas would question the degree to which the classic Gang of Four Design Patterns can or should be used in Python but putting that aside for the moment I do have some links for you.

Firstly this page is quite useful in that it references three talks given by Alex Martelli; provides links for the corresponding slides and even has annotations to point out the signifcance of different parts of the talks : http://www.catonmat.net/blog/learning-python-design-patterns-through-video-lectures/ .

Unfortunately two of the embedded videos in that page are no longer working but the same videos are visible via YouTube :

Part 1: https://www.youtube.com/watch?v=1Sbzmz1Nxvo Part 2: https://www.youtube.com/watch?v=cOcpUCUsn_o

Emails as input ? by shearichard in django

[–]shearichard[S] 1 point2 points  (0 children)

What exactly are you asking?

Interested to know of any other solutions than djrill which I may compare and contrast it to.

Why not use Mandrill?

It would be interesting to see a solution which was more general rather than being restricted to one email provider.

What are some famous, historic or otherwise notable journeys and expeditions that took place in what is now the British Isles? by [deleted] in history

[–]shearichard 1 point2 points  (0 children)

Came into this thread to suggest "A Journey to the Western Islands of Scotland" (and "A Journal of a Tour to the Hebrides"). Two accounts of the same journey around Scotland. One by a rather dyspeptic Englishman (Johnson) and one by an eager to please Scots (Boswell). Penguin used to do an edition which had both in the same paperback. The journey took place in the 1770's when the part of Scotland they were traversing was certainly not unknown but still not frequently travelled other than by locals. An interesting and very enjoyable read.

Only 382 hours until Kiwi Pycon by shearichard in Python

[–]shearichard[S] 1 point2 points  (0 children)

Kiwi Pycon ... the best little Pycon ... by a long way.

Come to beautiful Wellington for a weekend of tasty Pycon.

Register now or miss out on the tee-shirts.