Skip to content

Commit

Permalink
enable registering multiple plugins with same name
Browse files Browse the repository at this point in the history
by enumerating index field and adding it to the unique key
  • Loading branch information
megies committed Apr 29, 2016
1 parent 246804c commit 0fdd130
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion djangoplugins/management/commands/syncplugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ def plugins(self, point, point_inst):
src = self.get_classes_dict(point.plugins)
dst = self.get_instances_dict(point_inst.plugin_set.all())

for plugin, inst in self.available(src, dst, Plugin):
for _i, (plugin, inst) in enumerate(self.available(src, dst, Plugin)):
inst.point = point_inst
inst.name = getattr(plugin, 'name', None)
inst.index = _i
if hasattr(plugin, 'title'):
inst.title = six.text_type(getattr(plugin, 'title'))
inst.save()
Expand Down
2 changes: 1 addition & 1 deletion djangoplugins/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Plugin(DirtyFieldsMixin, models.Model):
objects = PluginManager()

class Meta:
unique_together = (("point", "name"),)
unique_together = (("point", "name", "index"),)
order_with_respect_to = 'point'
ordering = ('index', 'id')

Expand Down

0 comments on commit 0fdd130

Please sign in to comment.