Giter Club home page Giter Club logo

Comments (11)

SalahAdDin avatar SalahAdDin commented on May 13, 2024 1

Man, why put you a JET_INDEX_DASHBOARD if django-jet doesn't charge a custom dashboard by default? It's crazy. I think that this are a bug mine, but isn't it, it's a Django-Jet Bug

👍

from django-jet.

ohad-G avatar ohad-G commented on May 13, 2024 1

HI, this bug is a pain for me too,
Reset button ?
sql Command for reset on sqlite3 would be nice,
Thanks

from django-jet.

ShubhamBadal avatar ShubhamBadal commented on May 13, 2024

I am also facing exactly the same issue since many months.

from django-jet.

f1nality avatar f1nality commented on May 13, 2024

This is made mainly for storing widget's settings (title, some settings). What changes you do to dashboard file you don't want to be loaded from database?

from django-jet.

Ajeetlakhani avatar Ajeetlakhani commented on May 13, 2024

I need a multi-level dashboard so i am extending jet and making it hierarchial. So i would prefer loading it from file. Also in development its difficult to add more module and check because this function create new entry in database only when module_models is'nt there or its length is 0.

from django-jet.

SalahAdDin avatar SalahAdDin commented on May 13, 2024

@f1nality what's about this man?

I think that a possible solution will be use the same methos with this form:

class ResetDashboardForm(forms.Form):
    app_label = forms.CharField(required=False)

    def __init__(self, request, *args, **kwargs):
        self.request = request
        super(ResetDashboardForm, self).__init__(*args, **kwargs)

    class Meta:
        model = UserDashboardModule
        fields = []

    def clean(self):
        data = super(ResetDashboardForm, self).clean()
        data['app_label'] = data['app_label'] if data['app_label'] else None

        if not self.request.user.is_authenticated():
            raise ValidationError('error')

        return data

    def save(self, commit=True):
        if commit:
            UserDashboardModule.objects.filter(
                user=self.request.user.pk,
                app_label=self.cleaned_data['app_label']
            ).delete()

Use some this methods when load the custom template.

I think that when you use migrate on dashboard you load first default dashboard and it is set in database first. So, when you use reset, this function clean default dashboard sets in database and save the new dashboard, right?

from django-jet.

nryoung avatar nryoung commented on May 13, 2024

@Ajeetlakhani what do you mean by pressing the "reset" button here? Does this mean wiping out the database and starting fresh?

@f1nality This is rough bug to figure out. What is the work around to getting your dashboard to update with different modules? Wiping out the database isn't really an option for me. (I bought the license if that matters at all)

from django-jet.

nryoung avatar nryoung commented on May 13, 2024

I actually implemented a workaround for this. It involves overriding load_modules method on the Dashboard object. It now calls a new method called get_or_create_module_models every time which either gets that specific module from the DB if it exists, otherwise it creates it. This allows you to modify the Dashboard and it will update as you would expect it to.

from jet.dashboard.dashboard import Dashboard
from jet.dashboard.models import UserDashboardModule


class CustomIndexDashboard(Dashboard):
    columns = 3
    # Moderator Tools

    def init_with_context(self, context):
        self.available_children.append(modules.LinkList)

    def get_or_create_module_models(self, user):
        module_models = []

        i = 0

        for module in self.children:
            column = module.column if module.column is not None else i % self.columns
            order = module.order if module.order is not None else int(i / self.columns)

            obj, created = UserDashboardModule.objects.get_or_create(
                title=module.title,
                app_label=self.app_label,
                user=user.pk,
                module=module.fullname(),
                column=column,
                order=order,
                settings=module.dump_settings(),
                children=module.dump_children()
            )
            module_models.append(obj)
            i += 1

        return module_models

    def load_modules(self):
        module_models = self.get_or_create_module_models(self.context['request'].user)

        loaded_modules = []

        for module_model in module_models:
            module_cls = module_model.load_module()
            if module_cls is not None:
                module = module_cls(model=module_model, context=self.context)
                loaded_modules.append(module)

        self.modules = loaded_modules

from django-jet.

SalahAdDin avatar SalahAdDin commented on May 13, 2024

@nryoung good man, i think you should make a pull request: this feature have to be in this package by default. @f1nality isn't it?

from django-jet.

Ismael-VC avatar Ismael-VC commented on May 13, 2024

Please come to the django-jet Discord server so we can organize if you like:

Welcome! 😄

from django-jet.

SalahAdDin avatar SalahAdDin commented on May 13, 2024

@Ismael-VC , what's about this? Did you test it?

from django-jet.

Related Issues (20)

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.