Esempio n. 1
0
def load_models():
    if not session.get('cart_loaded_models'):
        session['cart_loaded_models'] = True
        classes = [x.get_class_from_db() for x in ProductType.objects.all()]
        print "loaded models"
        for c in classes:
            admin_class = type('{}Admin'.format(c.__name__), (BaseView, ), {})
            admin.register(c, name=_l(c.__name__), category=_("Cart"))
Esempio n. 2
0
        'available_at': ModelAdmin.formatters.get('datetime'),
        'values': ModelAdmin.formatters.get('ul'),
        'status': ModelAdmin.formatters.get('status'),
    }

    column_formatters_args = {
        'ul': {
            'values': {
                'placeholder': u"{item.campaign.title} - {item.value}",
                'style': "min-width:200px;max-width:300px;"
            }
        },
        'status': {
            'status': {
                'labels': {
                    'confirmed': 'success',
                    'checked_out': 'warning',
                    'cancelled': 'important',
                    'completed': 'success'
                },
                'style': 'min-height:18px;'
            }
        }
    }


admin.register(Campaign, CampaignAdmin,
               category=_("Fundraising"), name=_l("Campaign"))
admin.register(Donation, DonationAdmin,
               category=_("Fundraising"), name=_l("Donation"))
Esempio n. 3
0
    form_args = {
        "description": {
            "widget": TextEditor()
        },
        "identifier": {
            "widget": PrepopulatedText(master='title')
        }
    }
    form_columns = ('title', 'identifier', 'description', 'module', 'requires',
                    'image', 'link', 'config', 'pipeline', 'published')
    form_ajax_refs = {'image': {'fields': ['title', 'long_slug', 'summary']}}

    form_widget_args = {
        'config': {
            'cols': 40,
            'rows': 10,
            'style': 'width:500px;'
        }
    }


admin.register(Cart, CartAdmin, category=_("Cart"), name=_l("Cart"))
admin.register(Processor,
               ProcessorAdmin,
               category=_("Cart"),
               name=_l("Processor"))
admin.register(TestProduct,
               ProductAdmin,
               category=_("Cart"),
               name=_l("Products"))
Esempio n. 4
0
    def after_model_change(self, form, model, is_created):
        if not is_created and model.reference:
            model.reference.published = model.published
            if model.tax:
                model.set_reference_tax(float(model.tax))
            model.reference.save()


class ProcessorAdmin(ModelAdmin):
    roles_accepted = ('admin', 'developer')
    column_list = ('identifier', 'title', 'module', 'published')
    form_args = {
        "description": {"widget": TextEditor()},
        "identifier": {"widget": PrepopulatedText(master='title')}
    }
    form_columns = ('title', 'identifier', 'description', 'module',
                    'requires', 'image', 'link', 'config', 'pipeline',
                    'published')
    form_ajax_refs = {
        'image': {'fields': ['title', 'long_slug', 'summary']}
    }

    form_widget_args = {
        'config': {'cols': 40, 'rows': 10, 'style': 'width:500px;'}
    }

admin.register(Cart, CartAdmin, category=_("Cart"), name=_l("Cart"))
admin.register(Processor, ProcessorAdmin, category=_("Cart"),
               name=_l("Processor"))
Esempio n. 5
0
                }
                post, _ = Post.objects.get_or_create(**post)

                AggregatedTopic(
                    original_url=entry['feedburner_origlink'].encode(
                        'ascii', 'ignore'),
                    blog=blog,
                    post=post).save()


class AggregatedTopicAdmin(ModelAdmin):
    roles_accepted = ('admin', 'editor')
    column_filters = ('date_added', 'original_url', 'blog', 'post')
    column_searchable_list = ['original_url']
    column_list = ('date_added', 'blog', 'original_url', 'post')
    form_columns = ('date_added', 'blog', 'original_url', 'post')

    def on_model_delete(self, topic):
        topic.post.delete()


# Register RSSaggregator models to quokka admin page
admin.register(ExternalBlogs,
               ExternalBlogsAdmin,
               category=_("RSSaggregator"),
               name=_l("External Blogs"))
admin.register(AggregatedTopic,
               AggregatedTopicAdmin,
               category=_("RSSaggregator"),
               name=_l("Aggregated Topics"))