|
1 from django.db import models |
|
2 from django.contrib.auth.models import User |
|
3 from django.contrib.auth.models import Group, Permission |
|
4 |
|
5 |
|
6 |
|
7 # class ProblemPermission(models.Model): |
|
8 # """Abstract page permissions |
|
9 # """ |
|
10 # #who |
|
11 # user = models.ForeignKey(User) |
|
12 # #what |
|
13 # can_change = models.BooleanField("can edit", default=False) |
|
14 # can_add = models.BooleanField("can add", default=False) |
|
15 # can_delete = models.BooleanField("can delete", default=False) |
|
16 |
|
17 |
|
18 # class Meta: |
|
19 # abstract = True |
|
20 # app_label = 'testapp' |
|
21 |
|
22 PROBLEM_CHOICES=( |
|
23 ('P', 'Plotting'), |
|
24 ('S', 'Scripting'), |
|
25 ) |
|
26 |
|
27 |
|
28 SESSION_CHOICES=( |
|
29 ('A','DAY 1 SESSION 1'), |
|
30 ('B','DAY 1 SESSION 2'), |
|
31 ('C','DAY 1 SESSION 3'), |
|
32 ('D','DAY 1 SESSION 4'), |
|
33 ('E','DAY 2 SESSION 1'), |
|
34 ('F','DAY 2 SESSION 2'), |
|
35 ('G','DAY 2 SESSION 3'), |
|
36 ('H','DAY 1 SESSION 4'), |
|
37 ) |
|
38 |
|
39 class Problem(models.Model): |
|
40 # name = models.CharField(blank=False,max_length=255) |
|
41 description = models.CharField(blank=False , max_length=255) |
|
42 problem_type=models.CharField(blank = False ,max_length=1, choices=PROBLEM_CHOICES) |
|
43 solution = models.CharField(blank=True ,max_length=255) |
|
44 solution_image = models.ImageField(blank = True ,upload_to='plots') |
|
45 session = models.CharField(blank=False ,max_length=1,choices=SESSION_CHOICES) |
|
46 author = models.CharField(max_length=255) |
|
47 created = models.DateTimeField() |
|
48 modified = models.DateTimeField() |
|
49 |
|
50 |
|
51 |
|
52 #if user.has_perm('testapp.add_bar') and user.has_perm('foo.change_bar') and user.has_perm('foo.delete_bar') |
|
53 |
|
54 class Test_User(models.Model): |
|
55 #problem = models.ForeignKey('Problem') |
|
56 user = models.ForeignKey(User, unique=True) |
|
57 fullname=models.CharField(max_length=255) |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |