| Total Complexity | 1 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import logging |
||
| 2 | |||
| 3 | from django.contrib.auth.models import User |
||
| 4 | from django.db import models |
||
| 5 | |||
| 6 | from ore.models import Graph, Project |
||
| 7 | |||
| 8 | logger = logging.getLogger('ore') |
||
| 9 | |||
| 10 | |||
| 11 | class Sharing(models.Model): |
||
| 12 | |||
| 13 | """ |
||
| 14 | Class: Sharing |
||
| 15 | |||
| 16 | This class models a graph sharing, which represents the fact that a graph owner shared it's graph |
||
| 17 | with another user. |
||
| 18 | |||
| 19 | Fields: |
||
| 20 | {Graph} graph - The graph being shared. |
||
| 21 | {User} user - The user that got the graph shared by it's owner. |
||
| 22 | {datetime} created - The time when the graph as shared with the user. |
||
| 23 | {Project} project - The project that the shared graph belongs to on the non-owner side. |
||
| 24 | This is initially empty, which demands some handling by the frontend. |
||
| 25 | """ |
||
| 26 | class Meta: |
||
| 27 | app_label = 'ore' |
||
| 28 | |||
| 29 | graph = models.ForeignKey(Graph, related_name='sharings') |
||
| 30 | user = models.ForeignKey(User, related_name='sharings') |
||
| 31 | created = models.DateTimeField(auto_now_add=True, editable=False) |
||
| 32 | project = models.ForeignKey( |
||
| 33 | Project, |
||
| 34 | null=True, |
||
| 35 | default=None, |
||
| 36 | related_name='sharings') |
||
| 37 | |||
| 38 | def __unicode__(self): |
||
| 39 | return unicode('Graph %u shared with %s by %s.' % |
||
|
|
|||
| 40 | (self.graph.pk, self.user, self.graph.owner)) |
||
| 41 |