Skip to content

This simple script uses Discourse's REST API to duplicate a category, which is not possible directly through discourse's frontend.

License

Notifications You must be signed in to change notification settings

guipenedo/discourse-duplicate-category

Repository files navigation

Discourse duplicate category

This simple script uses Discourse's REST API to duplicate a category, which is not possible directly through the frontend.

Features

  • Copy category colors
  • Copy category images
  • Copy category permission groups
  • Optionally replace the original permission groups with new ones directly
  • Copy category settings (wiki, subcategory display options, etc)
  • Copy category description (the auto generated about post is edited with the contents of the origin category's about post)
  • Sub categories are recursively copied

Unfortunately the list of allowed tags is not copied at this time.

Obtaining an API key

On settings, click on API and then on the key icon to create a new API Key

Configuration

Rename the config.ini.default file to config.ini. Fill in the options:

[forum]
api_key= # put your API key here
api_user= # the username of the user associated with this API key
url= # Discourse installation base url, without trailing /

Installation

  1. Create a virtual environment
  2. Activate it
  3. Install the requirements
    $ pip install -r requirements.txt

Running

  1. Activate the virtual environment you created

  2. While in the main directory, run

    python3 main.py
  3. Choose a category to copy from (origin) by name

  4. Choose the name of the new category (destination)

  5. Choose the new category's slug

  6. Optionally, type in "yes" to indicate a group replacement mapping.

    For example, to replace astro-studs with math-studs and astro-teach with math-teach:

    Would you like to replace groups from the previous category with different ones, already created? (yes/no) yes
    How many groups? 2
    Old group 1/2: astro-studs
    New group 1/2: math-studs
    Old group 2/2: astro-teach
    New group 2/2: math-teach
    

    Please note that math-studs and math-teach groups must already exist.

  7. The script will now recursively duplicate the category and its subcategories

About

This simple script uses Discourse's REST API to duplicate a category, which is not possible directly through discourse's frontend.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages