1

In my website, there are many teams. The team members have powers. These powers are depending on the member's role.

On the website, some members can do actions specifics to role. Example: Member with the power to fly can create articles (class Article(Models.model) ) on the website.

I need help for the conception of my DB.

Currently, I have the following:

class Subscribe(models.Model):
    user = models.OneToOneField(User)
    ...

class Team(models.Model):
    name = models.CharField(...
    ...

class BelongsTeam(models.Model):
    username_subscribe=models.CharField(max_length=30)
    team = models.OneToOneField(Team, null=False)
    name_team= models.CharField(max_length=24) 

    class Meta :
        abstract = True

class Member(BelongsTeam):
    POWERS = (('Fast','Fast'),('Fly','Fly'))
    power = models.CharField(max_length=13,choices=POWERS,default='Fast')

So when new team recruits subscribe:

def recruits(request,usernamesubscribe,nameteam):
    the_team = Team.objects.get(name=nameteam) 
    member = Member(username_subscribe=usernamesubscribe,team=the_team,name_team=the_team.name)
    member.save()
    return render(...

This system works but I have doubts about the quality of this system.

Is it a good idea to use the Django groups system?

What do you think about my team system?

Zoulou
  • 303
  • 2
  • 16
  • What you are describing is Role based permissions. Maybe check out some packages in the https://www.djangopackages.com/grids/g/perms/ you may find a solution that fits your requirements. I would suggest you use django guardian – Fanis Despoudis Sep 12 '15 at 14:02
  • I don't want to use packages of others persons ^^. But my solution is bad ???? – Zoulou Sep 12 '15 at 14:08
  • Perhaps this is better suited to the [Core Review Stack Exchange](http://codereview.stackexchange.com/). – meshy Sep 12 '15 at 14:13
  • 2
    @meshy At its present state, this would be closed as "example code" on Code Review. Unlike Stack Overflow where it is recommended to minify the code as much as possible, Code Review wants context. For more information read [A Guide to Code Review for Stack Overflow users](http://meta.codereview.stackexchange.com/questions/5777/a-guide-to-code-review-for-stack-overflow-users) – Simon Forsberg Sep 12 '15 at 14:16

0 Answers0