django-helpdesk / django-helpdesk

A Django application to manage tickets for an internal helpdesk. Formerly known as Jutda Helpdesk.
BSD 3-Clause "New" or "Revised" License
1.54k stars 642 forks source link

Using django-helpdesk with an existing project based on django-allauth #912

Open regiov opened 3 years ago

regiov commented 3 years ago

I'm trying to use the new version of django-helpdesk (0.3x) with an existing project based on django-allauth and I'm getting a conflict error when I try to run the initial migration due to duplicate app labels (see error below).

So my first question would be: what is the best way to handle this particular error?

However, I fear there's a deeper question related to the fact that the new version of django-helpdesk seem to include its own underpinning for user management based on django-user-accounts. I wonder, how can the new django-helpdesk be integrated with existing projects that have their own custom user management already in place? Or is the new version supposed to only run with its own user management?

Thanks in advance!

Error mentioned:

$ python3 manage.py migrate helpdesk Traceback (most recent call last): File "manage.py", line 20, in execute_from_command_line(sys.argv) File "/usr/local/lib/python3.6/site-packages/Django-3.0.7-py3.6.egg/django/core/management/init.py", line 401, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.6/site-packages/Django-3.0.7-py3.6.egg/django/core/management/init.py", line 377, in execute django.setup() File "/usr/local/lib/python3.6/site-packages/Django-3.0.7-py3.6.egg/django/init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python3.6/site-packages/Django-3.0.7-py3.6.egg/django/apps/registry.py", line 95, in populate "duplicates: %s" % app_config.label) django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: account

gwasser commented 3 years ago

Is Pinax not compatible with django-allauth? I would say that's an oversight then, not intended to prevent other user management. If it's a label conflict I imagine we can rename the one in django-helpdesk before our full 0.3 release.

regiov commented 3 years ago

I'm afraid I'm completely unfamiliar with Pinax, so I don't have the answer. But my main doubt now is if django-helpdesk really depends now on django-user-accounts, as I depict from the new INSTALLED_APPS configuration in your install.rst. If that's the case, how can I use django-helpdesk with my own custom user model? Or is "account" an optional app for django-helpdesk?

gwasser commented 3 years ago

I just merged a commit from #913 to allow users to specify their own custom models without using pinax if you prefer. I hope that will help address this issue.

gwasser commented 3 years ago

Oops nevermind I was thinking of something different. Anyway, there's work on a commit to allow users to specify their own models if they prefer (but pinax will be the default for new installations that do not require any special integration).

On Wed, Dec 2, 2020 at 4:56 PM Renato notifications@github.com wrote:

I'm afraid I'm completely unfamiliar with Pinax, so I don't have the answer. But my main doubt now is if django-helpdesk really depends now on django-user-accounts, as I depict from the new INSTALLED_APPS configuration in your install.rst. If that's the case, how can I use django-helpdesk with my own custom user model? Or is "account" an optional app for django-helpdesk?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/django-helpdesk/django-helpdesk/issues/912#issuecomment-737519786, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEKHU6PONE6XO4FE63GVGLSS2ZXPANCNFSM4UIFNTGQ .

regiov commented 3 years ago

OK, I'll be happy to try that out. I've just cloned the current code and assumed I could simply not include in my INSTALLED_APPS: account, pinax.invitations, pinax.teams and reversion. However, I get an error when I try to perform the initial migration due to the fact that models.py still imports pinax. Any advice?

timthelion commented 3 years ago

The current code doesn't have the PR merged yet. I still need to fix the test suit so that the test suit is either configured to install pinax manually or to not use pinax. Can you try the PR along with setting the new config variables that the PR sets?

regiov commented 3 years ago

Sure! Apparently it worked. At least I was able to perform the initial migration and the server is running. I'll see what other tests I can run on my development environment. Many thanks for that! Let me know if there's anything else I can do to help.

timthelion commented 3 years ago

Would you mind sharing the exact values for the new config vars that you ended up using? Just so I know what has been tested? Thanks

regiov commented 3 years ago

I just followed the instructions. So far I have:

HELPDESK_TEAMS_MODEL = 'usr.Person' HELPDESK_TEAMS_MIGRATION_DEPENDENCIES = [] HELPDESK_KBITEM_TEAMGETTER = lambda : None

And INSTALLED_APPS contains only 'helpdesk' and 'bootstrap4form', besides the django apps, other apps that I use and my own apps.

timthelion commented 3 years ago

OK, thanks. So you just disabled teams... This means that the teams feature won't work, but that doesn't matter, the feature is optional...

nhonorisg commented 2 years ago

Hey!

I am working on a project with django-helpdesk, and I am stuck at the point of setting the app without pinax-teams because I have this error: ERRORS: helpdesk.KBItem.team: (fields.E300) Field defines a relation with model 'pinax_teams.Team', which is either not installed, or is abstract.

I tried to follow indications that I found on https://django-helpdesk.readthedocs.io/en/0.3/teams.html, but it is still not working for me. I will really appreciate if somebody can help me figure out the thing that I am probably messing up.

ndunn219 commented 1 year ago

I am using v.0.4.1 and get the same error that @regiov originally got because of the conflict between "allauth.account" and "account".

I tried disabling pinax using these settings

HELPDESK_TEAMS_MODEL = "myapp.DummyTeam"
HELPDESK_TEAMS_MIGRATION_DEPENDENCIES = []
HELPDESK_KBITEM_TEAM_GETTER = lambda _: None

Here's my DummyTeam model:

class DummyTeam(models.Model):
    """This model is used so that we don't have to use pinax-teams with django-helpdesk.
    See https://django-helpdesk.readthedocs.io/en/0.3/teams.html
    """

    pass

I also removed the pinax related apps from INSTALLED_APPS:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',  # Required for determining domain url for use in emails
    'django.contrib.admin',  # Required for helpdesk admin/maintenance
    'django.contrib.humanize',  # Required for elapsed time formatting
    'bootstrap4form', # Required for nicer formatting of forms with the default templates
    # 'account',  # Required by pinax-teams
    # 'pinax.invitations',  # Required by pinax-teams
    # 'pinax.teams',  # Team support
    # 'reversion',  # Required by pinax-teams
    'rest_framework',  # required for the API
    'helpdesk',  # This is us!
)

Now, when I go to admin/helpdesk/ticket/, I get this error:

 django.db.utils.ProgrammingError: column helpdesk_queue.enable_notifications_on_email_events does not exist

I checked the database, and that column does not exist. Here are the columns that are in in helpdesk_queue:

    id integer NOT NULL DEFAULT nextval('helpdesk_queue_id_seq'::regclass),
    title character varying(100) COLLATE pg_catalog."default" NOT NULL,
    slug character varying(50) COLLATE pg_catalog."default" NOT NULL,
    email_address character varying(75) COLLATE pg_catalog."default",
    locale character varying(10) COLLATE pg_catalog."default",
    allow_public_submission boolean NOT NULL,
    allow_email_submission boolean NOT NULL,
    escalate_days integer,
    new_ticket_cc character varying(200) COLLATE pg_catalog."default",
    updated_ticket_cc character varying(200) COLLATE pg_catalog."default",
    email_box_type character varying(5) COLLATE pg_catalog."default",
    email_box_host character varying(200) COLLATE pg_catalog."default",
    email_box_port integer,
    email_box_ssl boolean NOT NULL,
    email_box_user character varying(200) COLLATE pg_catalog."default",
    email_box_pass character varying(200) COLLATE pg_catalog."default",
    email_box_imap_folder character varying(100) COLLATE pg_catalog."default",
    email_box_interval integer,
    email_box_last_check timestamp with time zone,
    socks_proxy_type character varying(8) COLLATE pg_catalog."default",
    socks_proxy_host inet,
    socks_proxy_port integer

My preference would be to use pinax-teams if possible (or at least to try it out), but if that's not possible, how can I fully disable it and still get django-helpdesk to work? Thanks!

uhurusurfa commented 1 year ago

Check if all the helpdesk migrations have ctually executed by looking in the django_migrations table in the database. Specifically 0023_add_enable_notifications_on_email_events_to_ticket

uhurusurfa commented 1 year ago

Hoping to get pinax projects upgraded to support Django 4 in the coming weeks - just waiting for the maintainers to add me as a maintainer.

ndunn219 commented 1 year ago

I switched branches and recreated the database, so I can't query it now, but I did run showmigrations when I was working on this, and it did run 0023_add_enable_notifications_on_email_events_to_ticket. Here are the full results (again, this is with the pinax apps commented out in INSTALLED_APPS):

Here is the result of showmigrations: What do the Xs mean?
[X] 0001_initial
[X] 0002_populate_usersettings
[X] 0003_initial_data_import
[X] 0004_add_per_queue_staff_membership
[X] 0005_queues_no_null
[X] 0006_email_maxlength
[X] 0007_max_length_by_integer
[X] 0008_extra_for_permissions
[X] 0009_migrate_queuemembership
[X] 0010_remove_queuemembership
[X] 0011_admin_related_improvements
[X] 0012_queue_default_owner
[X] 0013_email_box_local_dir_and_logging
[X] 0014_usersettings_related_name
[X] 0015_expand_permission_name_size
[X] 0016_alter_model_options
[X] 0017_default_owner_on_delete_null
[X] 0018_ticket_secret_key
[X] 0019_ticket_secret_key
[X] 0020_depickle_user_settings
[X] 0021_voting_tracker
[X] 0022_add_submitter_email_id_field_to_ticket
[X] 0023_add_enable_notifications_on_email_events_to_ticket
[X] 0024_time_spent
[X] 0025_queue_dedicated_time
[X] 0026_kbitem_attachments
[X] 0027_auto_20200107_1221
[ ] 0028_kbitem_team
[ ] 0029_kbcategory_public
[ ] 0030_add_kbcategory_name
[ ] 0031_auto_20200225_1440
[ ] 0032_kbitem_enabled
[ ] 0033_ticket_merged_to
[ ] 0034_create_email_template_for_merged
[ ] 0035_alter_email_on_ticket_change
[ ] 0036_add_attachment_validator

I don't know why it didn't run from 0028 on. I tried making migrations again, but it said that there were none to make.

uhurusurfa commented 1 year ago

Some of the migrations don't actually have any affect on the database (changes to dropdown list values for instance) but I am not sure if that is why they show without an X. It is odd that the migration appears to have run for your missing column but the column is not there and the reason could be any one of a number I can think of so the solution is hard to figure out. I would suggest you manually add the column: alter table queue add column enable_notifications_on_email_events boolean;

ndunn219 commented 1 year ago

Thanks for the suggestion, but that seems a little scary to me. :-)

When you work on pinax projects, are you planning to fix the issue with the conflict with django-allauth? If so, I'll wait for that and I am happy to test it out for you if that's helpful.

uhurusurfa commented 1 year ago

There is no simple way to use 2 projects with the same name if the file names and paths within the projects are the same and especially if both projects with the same name contain migrations. Pinax projects are tightly integrated and it is more or less all or nothing so django-allauth is not usable if you use Pinax teams. I will see if I can make it easy to exclude the Pinax teams stuff from this app so that there is nothing to do to exclude the teams plugin - it will be left out by default and no need to create fake objects.

timthelion commented 1 year ago

Dissabling teams entirely is already easy. It is documented here: https://django-helpdesk.readthedocs.io/en/0.3/teams.html

ndunn219 commented 1 year ago

Dissabling teams entirely is already easy. It is documented here: https://django-helpdesk.readthedocs.io/en/0.3/teams.html

Thanks, but I tried that and documented the result above. Perhaps I did something wrong.

scuc commented 11 months ago

@ndunn219 did you ever resolve this issue?
I'm having the exact same problem - unable to migrate past migration 0027 I created an empty model called EmptyTeam - when I run the migration it gets to 0028 and errors with: ValueError: Related model 'emptyteam' cannot be resolved

I'm guessing it has something to do with this settingHELPDESK_KBITEM_TEAM_GETTER = lambda _: None but i have no idea how to fix it. any help would be appreciated.

uhurusurfa commented 11 months ago

Have you tried using these settings:

            HELPDESK_TEAMS_MODEL='auth.User',
            HELPDESK_TEAMS_MIGRATION_DEPENDENCIES=[],
            HELPDESK_KBITEM_TEAM_GETTER=lambda _: None,
ndunn219 commented 11 months ago

did you ever resolve this issue?

@scuc, I did not. I eventually gave up. 😟

scuc commented 11 months ago

@uhurusurfa thank you!

based on your suggestion, I tried these settings:

HELPDESK_TEAMS_MODEL=users.User #my projects user model

And that allowed the migrations to complete.

HELPDESK_TEAMS_MODEL = "users.User"
HELPDESK_TEAMS_MIGRATION_DEPENDENCIES = []
HELPDESK_KBITEM_TEAM_GETTER = lambda _: None
Running migrations:
  Applying helpdesk.0028_kbitem_team... OK
  Applying helpdesk.0029_kbcategory_public... OK
  Applying helpdesk.0030_add_kbcategory_name... OK
  Applying helpdesk.0031_auto_20200225_1440... OK
  Applying helpdesk.0032_kbitem_enabled... OK
  Applying helpdesk.0033_ticket_merged_to... OK
  Applying helpdesk.0034_create_email_template_for_merged... OK
  Applying helpdesk.0035_alter_email_on_ticket_change... OK
  Applying helpdesk.0036_add_attachment_validator... OK
  Applying helpdesk.0037_alter_queue_email_box_type... OK
  Applying helpdesk.0038_checklist_checklisttemplate_checklisttask... OK