Don't allow script to be edited in the command admin.

Add unique_together to create a constraint and create an index that I expect to use.
 - Legacy-Id: 357
This commit is contained in:
Bill Fenner 2007-06-13 04:13:23 +00:00
parent 927e07b53f
commit 5de4ca9004

View file

@ -44,12 +44,14 @@ class Command(models.Model):
""" """
command = models.CharField(maxlength=50, core=True) command = models.CharField(maxlength=50, core=True)
url = models.CharField(maxlength=50, blank=True) url = models.CharField(maxlength=50, blank=True)
script = models.ForeignKey(Redirect, edit_inline=models.TABULAR, related_name='commands') script = models.ForeignKey(Redirect, edit_inline=models.TABULAR, related_name='commands', editable=False)
suffix = models.ForeignKey(Suffix, null=True, blank=True) suffix = models.ForeignKey(Suffix, null=True, blank=True)
def __str__(self): def __str__(self):
ret = "%s?command=%s" % (self.script.cgi, self.command) ret = "%s?command=%s" % (self.script.cgi, self.command)
if self.suffix_id: if self.suffix_id:
ret += " %s" % (self.suffix) ret += " %s" % (self.suffix)
return ret return ret
class Meta:
unique_together = (("script", "command"), )
class Admin: class Admin:
pass pass