Coder Social home page Coder Social logo

django-pimp-my-filter's Introduction

django-pimp-my-filter

Use it at your own risk! Alpha-dev version, as is.

Required:

  • Twitter Bootstrap 2.3+
  • jQuery 1.9+

This app is designed to pimp your filter for any model, but for now it's unfinnished.. yet :)

PIMP

How to use:

  1. Open your shell, cd /to/some/path
  2. Run git clone https://github.com/fynjah/django-pimp-my-filter.git
  3. Run cd django-pimp-my-filter
  4. Run [sudo] python setup.py install
  5. Now app is installed.

Connect app to your project:

  1. Open settings.py of your project. At the end of the file write INSTALLED_APPS += ('filter_manager',).
  2. Also add this:
    PIMP_MY_FILTER = {
        'ALLOWED_MODELS': (
            'your_app1.your_model1', 
            'your_app2.your_model2',
            ...
            'appN.modelN',
        ),
    }
Any other models will be ignored with error.
3. Open ``urls.py`` file. Edit ``urlpatterns`` by adding ``('^pimp-my-filter/', include('filter_manager.urls')),``
4. Open your shell, find your project and run `python manage.py syncdb`.
5. Insert [this code](https://raw.github.com/fynjah/django-pimp-my-filter/master/filter_manager/templates/base.html) to your template, somewhere.
6. Insert ``{%load% static%}`` and ``{% get_static_prefix as static_prefix %}`` to your template, at the top of the file.
7. Insert somewhere *after* jQuery and Twitter Bootstrap inits, this: ``<script type="text/javascript" src="{{ static_prefix }}filter_manager/filter_manager.js "></script>``
  1. Place somewhere in template, this:
	    $(document).ready(function(){
	        $(document).on('click', '#new-filter-button', function(e){
	                    e.preventDefault()
	                    $('#new-filter').pimpMyFilter({
	                        name:'Name of your modal',
	                        app:'your_app_to_use_filter_manager',
	                        model:'your_model_of_the_app_to_use_filter', 
	                        modalWidth:1000, //width of modal, req. from "800" to "1000". But, anyway it's fluid. default:"800"
	                        url:"/your_url_pattern_to_filter_manager/" //default: "/pimp-my-filter/",
	                        limit:10, //default: '0'. Limit num of conditions.
	                    });
	                });
	            });
  1. Start your project, jump to page with edited template and click this pretty button New filter
  2. You'll see modal window, something like on the pic at the top of this README.
  3. Try to select some field. Each type of field has own value field, that corresponds to type of field in model.
  4. Try to select ForeignKey field(find name of field in your model), and try to start typing in value field.
  5. That's it.

JS API

  1. Resize modal: pimpMyFilter.setModalWidth(1000)
  2. Redefine value field( not tested ):
     	pimpFields.[type_of_field] = function(ModelField){ 
     	//ModelField comes from pimpMyFilter.settings.structure
     	//ModelField = {"name":"some_name","type":"some_type"}. Use it.
    
                         field = this.__AbstractInputField();
                         //or field = this.__AbstractSelectField();
                         //..
                         //... Your definition of field, e.g field.css(), etc
                         //..
                         return field;
     	}
     
  3. Get filters by current user:
	pimpMyFilter.getFiltersByUser();

It returs object with id, name and quick. 4. Use saved filter:

	pimpMyFilter.userFilter(filter_id);

where filter_id - is from pimpMyFilter.getFiltersByUser();

Known issues

  1. Some bugs with HTML markup, but works nice with Chrome.
  2. For this moment you CAN use filters, but some fields do not work at this moment.
  3. Lot of other bugs, which I will fix soon:)

TODO

  1. Tags
  2. Fix fields in views.py
  3. API

PS: This app is designed for modern browsers! Stop supporting old versions of IE!

django-pimp-my-filter's People

Contributors

fynjah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.