class CategorieFaq(models.Model): categorie = models.CharField(max_length=200, blank=True, null=True) icon = IconField(blank=True, null=True) slug = models.CharField(max_length=200, blank=True, null=True) def __str__(self): return self.categorie
class SocialAccount(models.Model): ACCOUNT_CHOICES = ( ('facebook', 'Facebook'), ('twitter', 'Twitter'), ('linkedlin', 'LinkedIn'), ('google+', 'Google+'), ('youtube', 'YouTube'), ('instagram', 'Instagram'), ('pinterest', 'Pinterest'), ('tumblr', 'Tumblr'), ('snapchat', 'Snapchat'), ('reddit', 'Reddit'), ('flickr', 'Flickr'), ('foursquare', 'Foursquare'), ('kik', 'Kik'), ('yikyak', 'Yik Yah'), ('shots', 'Shots'), ('periscope', 'Periscope'), ) person = models.ForeignKey( Person, related_name='accounts', blank=True, null=True) icon = IconField() type = models.CharField( max_length=5, choices=ACCOUNT_CHOICES, blank=True, null=True) url = models.URLField(max_length=250, blank=True) class Meta: verbose_name_plural = "Accounts"
class Socail(models.Model): name = models.CharField(max_length=20) solid_link = models.CharField(max_length=120) icon = IconField() def __str__(self): return self.name
class Author(models.Model): image = models.ImageField(upload_to="photos/%Y/%m/%d/", blank=True) name = models.CharField(max_length=100) email = models.CharField(max_length=100) job = models.CharField(max_length=100, blank=True) info = models.CharField(max_length=260, blank=True) facebook = IconField() twitter = IconField() instagram = IconField() github = IconField() link1 = models.URLField(blank=True) link2 = models.URLField(blank=True) link3 = models.URLField(blank=True) link4 = models.URLField(blank=True) def __str__(self): return self.name
class Service(MainSiteContentChildAbstractBase): """ A service rendered in the "Services" section carousel """ name = models.CharField(max_length=50) description = models.CharField(max_length=300) icon = IconField()
class Sympathizer(TimeStampedModel, FollowersModel): created_by = models.ForeignKey(User) name = models.CharField(max_length=20, verbose_name='Nazwa', unique=True) slug = models.SlugField(max_length=20, unique=True) icon = IconField(verbose_name='Ikona', default='exclamation', blank=True) def __str__(self): return self.name
class University(models.Model): nom_complet = models.CharField(max_length=200) abreviation = models.CharField(max_length=200, blank=True, null=True) icon = IconField(blank=True, null=True) logo = models.ImageField(upload_to='mes_images/', blank=True, null=True) def __str__(self): return self.nom_complet
class Service(models.Model): icons = IconField() profession = models.CharField(max_length=200) text = models.TextField(blank=True) added_date = models.DateTimeField(blank=True) def __str__(self): return self.profession
class TipoObjeto(models.Model): id = models.AutoField(primary_key=True, blank=False, null=False) nome = models.CharField(max_length=50, blank=True, null=True) icone = IconField () def __str__(self): return self.nome class Meta: verbose_name = "Tipo de objeto" verbose_name_plural = "Tipos de objeto"
class Category(MPTTModel): name = models.CharField(max_length=200) alias_url = models.CharField(max_length=200) update_date = models.DateTimeField('Date de mise à jour', auto_now=True) parent = TreeForeignKey('self', blank=True, null=True, related_name = 'children',db_index=True) icon = IconField() def icon_display(self): return '<i class="fa fa-%s" style="color:green"> </i>' % (self.icon) icon_display.allow_tags = True def __str__(self): return self.name
class Service(models.Model): icon = IconField() image = models.ImageField(upload_to="photos/%Y/%m/%d/") job = models.CharField(max_length=100) description = models.TextField() def __str__(self): return self.job def summary(self): return self.description[:150]
class Faculte(models.Model): nom_complet = models.CharField(max_length=200) abreviation = models.CharField(max_length=200, blank=True, null=True) universite = models.ForeignKey( University, on_delete=models.CASCADE, ) icon = IconField(blank=True, null=True) logo = models.ImageField(upload_to='mes_images/', blank=True, null=True) def __str__(self): return self.nom_complet
class OrganilabNode(MPTTModel): name = models.CharField(max_length=300) description = models.TextField(null=True, blank=True) parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children') icon = IconField(null=True, blank=True) image = models.ImageField(upload_to="nodes/", null=True, blank=True) def __str__(self): return self.name class MPTTMeta: order_insertion_by = ['name']
class Footer(models.Model): site_about = models.CharField(max_length=300) street_num = models.CharField(max_length=100, blank=True) street_name = models.CharField(max_length=100, blank=True) city = models.CharField(max_length=100, blank=True) state = models.CharField(max_length=100, blank=True) country = models.CharField(max_length=100, blank=True) address_link = models.URLField(blank=True) twitter = IconField() instagram = IconField() github = IconField() linkedin = IconField() twi_link = models.URLField(blank=True) insta_link = models.URLField(blank=True) github_link = models.URLField(blank=True) linkedin_link = models.URLField(blank=True) java_link = models.URLField(blank=True) css_link = models.URLField(blank=True) html_link = models.URLField(blank=True) python_link = models.URLField(blank=True) php_link = models.URLField(blank=True)
class SocialAccount(models.Model): title = models.CharField(max_length=100) order = models.PositiveSmallIntegerField() visible = models.BooleanField(default=True) icon = IconField() link = models.URLField(blank=True) def __unicode__(self): return "%s" % self.title class Meta: verbose_name = 'Social Account Links' verbose_name_plural = 'Social Account Links'
class POIType(models.Model): label = models.CharField(max_length=30) slug = AutoSlugField(populate_from="label", always_update=True) icon = IconField() icon_file = FilerImageField(null=True, blank=True, on_delete=models.SET_NULL) color = models.CharField(max_length=30, null=True, blank=True) def get_typed_poi_count(self): return self.poi_set.count() def __unicode__(self): return "%s (%s)" % (self.label, self.get_typed_poi_count())
class Tracker(SortableMixin): createur = SortableForeignKey(Profil, verbose_name='créateur', related_name='trackers', on_delete=models.CASCADE) nom = models.CharField(max_length=100) icone = IconField('icône') color = ColorField('couleur', default='#FFFFFF') date_creation = models.DateTimeField('date de création', auto_now_add=True) order = models.PositiveIntegerField(default=0, editable=False, db_index=True) class Meta: unique_together = (('createur', 'nom'), ) ordering = ['order'] def __str__(self): return self.nom def get_absolute_url(self): return reverse('tracker:detail-tracker', kwargs={'pk': self.id}) def track_by_hour(self): hours = {} for i in range(24): hours[str(i)] = 0 for track in self.tracks.all(): hours[str(track.datetime.hour)] += 1 return hours def track_by_day(self): weekdays = { 0: 'Lundi', 1: 'Mardi', 2: 'Mercredi', 3: 'Jeudi', 4: 'Vendredi', 5: 'Samedi', 6: 'Dimanche' } days = {} for weekday in weekdays.values(): days[weekday] = 0 for track in self.tracks.all(): days[weekdays[track.datetime.weekday()]] += 1 return days
class Dependencia(models.Model): TIPO_DEPENDENCIA = (('CD', 'Consejo Directivo'), ('A', 'Área'), ('C', 'Comisión')) tipo = models.CharField(max_length=20, choices=TIPO_DEPENDENCIA) icono = IconField() coordinador = models.ManyToManyField('Dirigente') miembro = models.ManyToManyField('Dirigente', blank=True, related_name='miembro') nombre = models.CharField(max_length=50) objetivo_general = models.TextField() objetivo_especifico = models.TextField(blank=True) def __unicode__(self): return "%s" % self.nombre
class ArticleType(models.Model): name = models.CharField(max_length=255) slug = models.SlugField(unique=True, max_length=80) icon = IconField() panels = [ FieldPanel('name'), FieldPanel('slug'), FieldPanel('icon'), ] def __str__(self): return self.name class Meta: verbose_name = "Type" verbose_name_plural = "Types"
class SousCategorie(models.Model): nom = models.CharField(max_length=200) icon = IconField() categorie = models.ForeignKey( Categorie, on_delete=models.CASCADE, ) def __str__(self): return self.nom def get_cours(self): cours_ids = SousCategorieCours.objects.filter( sous_categorie=self).values_list('cours', flat=True) cours = Cours.objects.filter(id__in=cours_ids) return set(cours)
class Service(models.Model): name = models.CharField('Nome', max_length=100) slug = models.SlugField('Atalho') description = models.TextField('Descrição ', blank=True) icon = IconField() prepopulated_fields = {'slug': ['name']} def __str__(self): return self.name @models.permalink def get_absolute_url(self): return ('home:details', (), {'slug': self.slug}) class Meta: verbose_name = 'Serviço' verbose_name_plural = 'Serviços' ordering = ['name']
class Cible(models.Model): nom = models.CharField(max_length=200) image = models.ImageField(upload_to='mes_images/') description = models.TextField() icon = IconField() ordre = models.PositiveSmallIntegerField(default=1) def __str__(self): return self.nom class Meta: ordering = ('ordre', ) def get_cours(self): cibles_cours = CibleCours.objects.filter(cible=self) cours_ids = cibles_cours.values_list('cours', flat=True) cours = Cours.objects.filter(id__in=cours_ids) return set(cours)
class Categorie(models.Model): nom = models.CharField(max_length=200) icon = IconField() image = models.ImageField(upload_to='mes_images/', blank=True, null=True) def __str__(self): return self.nom def get_number_cours(self): souscategorie_ids = self.souscategorie_set.all().values_list('id', flat=True) cours = SousCategorieCours.objects.filter( sous_categorie__id__in=souscategorie_ids).values_list('cours', flat=True) return len(set(cours)) def get_cours(self): souscategorie_ids = self.souscategorie_set.all().values_list('id', flat=True) cours_ids = SousCategorieCours.objects.filter( sous_categorie__id__in=souscategorie_ids).values_list('cours', flat=True) cours = Cours.objects.filter(id__in=cours_ids) return set(cours)
class Image(models.Model): image = models.ImageField(upload_to="gallery/") image_name = models.CharField(max_length=10) image_url = models.URLField(null=True, blank=True) image_description = models.CharField(max_length=30) location = models.ForeignKey(Location, on_delete=models.DO_NOTHING) category = models.ManyToManyField(Category) created_on = models.DateTimeField(auto_now_add=True) icon = IconField() class Meta: ordering = ["-created_on"] @classmethod def all_images(cls): pics = cls.objects.all() return pics @classmethod def display_category(cls, category): pics = cls.objects.filter(category=category) return pics @classmethod def fetch_images_in_category(cls, category_id): return cls.objects.filter(category__id=category_id) @classmethod def filter_by_location(cls, location_id): return cls.objects.filter(location=location_id) @classmethod def search_by_category(cls, search_term): return cls.objects.filter(category__name__icontains=search_term) @classmethod def save_image(cls, *args, **kwargs): if cls.image_url: file_save_dir = cls.upload_path filename = urlparse(cls.image_url).path.split("/")[-1] urllib.urlretrieve(cls.image_url, os.path.join(file_save_dir, filename)) cls.image = os.path.join(file_save_dir, filename) cls.image_url = "" super(Image, cls).save() def delete(self, *args, **kwargs): if os.path.isfile(self.image_url.path): os.remove(self.image_url.path) super(Image, self).delete(*args, **kwargs) @classmethod def get_image_by_id(cls, id): return cls.objects.filter(id=id) @classmethod def search_image(cls, category): return cls.objects.filter(category__name__icontains=category) def __str__(self): return self.image_name
class Category(models.Model): icon = IconField()
class Matiere(models.Model): nom = models.CharField(max_length=200) icon = IconField() def __str__(self): return self.nom
class ClassroomMenuItem(TimeStampedModel): """ Classroom Menu Items make up the Classroom Menu dependent on courseevent ClassLessons and Classlessonsteps may be published in the class through an entry in the menu. The same is true for forums. Also certain links may be published that way: - link to particpant list - link to latest forum contributions """ courseevent = models.ForeignKey(CourseEvent) classlesson = models.ForeignKey(ClassLesson, blank=True, null=True, related_name="lesson") forum = models.ForeignKey(Forum, blank=True, null=True, on_delete=models.PROTECT) icon = IconField( verbose_name="Icon", help_text="Neben dem Menüeintrag kann ein Icon angezeigt werden.") menuitemtype = enum.EnumField(MenuItemType, default=MenuItemType.LESSON) MENU_ITEM_TYPE = Choices( ('header', 'header_item', _('Überschrift')), ('lesson', 'lesson_item', _('Lektion')), ('forum', 'forum_item', _('Forum')), ('announcements', 'announcements_item', _('Ankündigungsliste')), ('participants', 'participants_item', _('Teilnehmerliste')), ) item_type = models.CharField( verbose_name="Typ des Menüpunkts", help_text= """Welcher Art ist der Menüeintrag: Überschrift, Link, etc?""", choices=MENU_ITEM_TYPE, max_length=15) is_shortlink = models.BooleanField( verbose_name='Kurzlink', help_text="""die wichtigsten Links werden als Kurzlinks angezeigt. Es sollte nicht mehr als 10 Kurzlinks geben""", default=False) display_nr = models.IntegerField( verbose_name="Reihenfolge Nummer", help_text= """An welcher Position im Menü soll der Menüpunkt angezeigt werden?""", ) display_title = models.CharField(max_length=200) is_start_item = models.BooleanField( verbose_name="Ist Startpunkt", help_text="""Welcher Menüpunkt soll im Klassenzimmer als erstes angesprungen werden?""", default=False) objects = ClassroomMenuItemManager() shortlinks = QueryManager(is_shortlink=True).order_by('display_nr') unique_together = ('display_title', 'courseevent') class Meta: verbose_name = _("Menüeintrag") verbose_name_plural = _("Menüeinträge") def __unicode__(self): return u'%s' % (self.display_title) def save(self, *args, **kwargs): """ menu item save method if the saved item is a start item, the start item must be switched to the current item, since there can be no more then one startitem per courseevent. """ if self.is_start_item: switch_start_item(self) super(ClassroomMenuItem, self).save(*args, **kwargs) def clean(self): """ checks input in relation to item_type 1. header items cannot be shortlinks or startitems, since they are no links 2. lesson_item: relation to lesson is required 3. lessonstep_item: relation to lesson_step is required 4. forum_item: relationship to forum is required """ # 1. header item: not start_item, no relationships allowed if self.item_type == self.MENU_ITEM_TYPE.header_item: if self.is_start_item: raise ValidationError( 'Überschrift kann nicht Startpunkt sein!') if self.is_shortlink: raise ValidationError( 'Überschrift kann nicht ins Kurzmenü eingehägt werden!') # 2. lesson item: only relationship to lesson is required if self.item_type == self.MENU_ITEM_TYPE.lesson_item: if self.classlesson: if not self.classlesson.is_lesson(): raise ValidationError( '''Lektions-Eintrag muss zu einer Lektion verlinken.''', code='invalid_object') if self.forum: raise ValidationError('''Bei diesem Eintragstyp kann kein Forum angegeben werden.''') # 4. forum_item: only relationships forum, is required if self.item_type == self.MENU_ITEM_TYPE.forum_item: if not self.forum: raise ValidationError( '''Forum-Eintrag muss zu einem Forum verlinken. Bitte ein Forum auswählen.''') if self.classlesson: raise ValidationError('''Bei Eintragstyp kann keine Lektion angegeben werden.''')
class BaseLesson(MPTTModel): """ Base Lessons is an abstract model and a blueprint for both Lessons an ClassLessons. It depends on course. """ parent = TreeForeignKey( 'self', verbose_name="einhängen unter", null=True, blank=True, related_name='children', db_index=True, ) # dependant on course course = models.ForeignKey(Course, on_delete=models.PROTECT) nr = models.IntegerField(verbose_name=_('Nr.'), help_text=_('steuert nur die Anzeigereihenfolge'), default=1) icon = IconField( verbose_name="Icon", help_text="Neben dem Menüeintrag kann ein Icon angezeigt werden.") # this field is derived from nr and and parent.nr depending on the level # see save_method lesson_nr = models.CharField( verbose_name=_('Lektionsnr.'), help_text='abgeleitetes Feld: keine manuelle Eingabe', blank=True, max_length=10, editable=False) title = models.CharField(verbose_name="Überschrift", help_text="Lektions-Titel", max_length=100) text = models.TextField(verbose_name="Lektionstext", help_text="Text der Lektion", blank=True) description = models.CharField( verbose_name='Beschreibung', help_text="diese Beschreibung erscheint nur in den Übersichten", max_length=200, blank=True) material = models.ForeignKey(Material, verbose_name="Kursmaterial", help_text="Material der Lektion", blank=True, null=True) show_number = models.BooleanField(default=True, verbose_name="Nr. ist Lektionsnummer") is_homework = models.BooleanField(default=False) allow_questions = models.BooleanField(default=False) show_work_area = models.BooleanField(default=False) objects = BaseLessonManager() # lesson type: blocks > lesson > step having levels: 0, 1, 2 #LESSON_TYPE = Choices( # ('block', _('Block')), # ('lesson', _('Lesson')), # ('step', _('Step')),) class Meta: verbose_name = "Lektion" verbose_name_plural = "Lektionen" abstract = True class MPTTMeta: order_insertion_by = ['course', 'nr'] def __unicode__(self): """ blocks are just shown by their title, lessons are shown as <block-title>: <lesson_nr>. <lesson_title> and lessonsteps are shown as <lesson_nr>. <lesson_title> :return: self representation """ if self.level == 0: return u'Wurzel: %s' % (self.course) elif self.level == 1: return u'Block: %s' % (self.title) elif self.level == 2: return u'%s: %s. %s' % (self.parent.title, self.lesson_nr, self.title) elif self.level == 3: return u'%s %s' % (self.lesson_nr, self.title) def save(self, *args, **kwargs): """ lesson_nr is calculated and stored in the database for performance """ if self.level: if self.level == 1: self.lesson_nr = lesson_nr_block(nr=self.nr) elif self.level == 2: self.lesson_nr = lesson_nr_lesson(nr=self.nr) elif self.level == 3: self.lesson_nr = lesson_nr_step(nr=self.nr, parent_nr=self.parent.nr) super(BaseLesson, self).save(*args, **kwargs) #@property #def lesson_type(self): # """ # this just translates the internal level of the lesson into a level type, # see above. # :return: lesson_type: block, lesson or step # """ # if self.level == 1 : # return self.LESSON_TYPE.block # elif self.level == 2 : # return self.LESSON_TYPE.lesson # elif self.level == 3 : # return self.LESSON_TYPE.step @property def lesson_type(self): """ this just translates the internal level of the lesson into a level type, see above. :return: lesson_type: block, lesson or step """ if self.level == 0: return LessonType.ROOT elif self.level == 1: return LessonType.BLOCK elif self.level == 2: return LessonType.LESSON elif self.level == 3: return LessonType.LESSONSTEP def breadcrumb(self): """ in breadcrumbs a different representation is chosen for block. lesson and step block: <title> lesson: <lesson_nr>. <title> lessonstep: <lesson_nr> <title> :return: representation in breadcrumbs """ if self.level == 1 or not self.show_number: return u'%s' % (self.title) elif self.level == 2: return u'%s. %s' % (self.lesson_nr, self.title) elif self.level == 3: return u'%s %s' % (self.lesson_nr, self.title) def get_delete_tree(self): return self.get_descendants( include_self=True).select_related('material') def get_next_sibling(self): """ for blocks the mptt method get_next_sibling needs to be overwritten, so that it stays into the course :return: None or next mptt-sibiling """ next = super(BaseLesson, self).get_next_sibling() try: if next.course_id == self.course_id: return next else: return None except: return None def get_previous_sibling(self): """ for blocks the mptt method get_previous_sibling needs to be overwritten, so that it stays into the course :return: None or previous mptt-sibiling """ previous = super(BaseLesson, self).get_previous_sibling() try: if previous.course_id == self.course_id: return previous else: return None except: return None def get_breadcrumbs_with_self(self): return self.get_ancestors(include_self=True).exclude(level=0) def get_tree_with_self_with_material(self): """ gets real decendants and materials of a node :return: real decendants with material """ return self.get_descendants( include_self=True).select_related('material') def get_tree_without_self_with_material(self): """ gets real decendants and materials of a node :return: real decendants with material """ return self.get_descendants( include_self=False).select_related('material') def get_tree_without_self_without_material(self): """ gets real decendants but not the materials of a node :return: real decendants without material """ return self.get_descendants(include_self=False) def is_block(self): """ bool that decides wether a lesson is a block :return: bool """ if self.get_level() == 1: return True else: return False def is_lesson(self): """ bool that decides wether a lesson is a lesson :return: bool """ if self.get_level() == 2: return True else: return False def is_step(self): """ bool that decides wether a lesson is a step :return: bool """ if self.get_level() == 3: return True else: return False def is_owner(self, user): """ Is this person a teacher in this course? (Then he may work on it.) :param user :return: bool """ if self.course.is_owner(user): return True else: return False