Welcome, guest | Sign In | My Account | Store | Cart

this is a exemple of OS

Python, 49 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from django.db import models


class Projeto(models.Model):
    nome_proj = models.CharField(max_length=50)
    desc_proj = models.TextField()
   
    def __unicode__(self):
        return u'%s' % self.nome_proj


class Funcionario(models.Model):
    nome_func = models.CharField(max_length=20)
    sobrenome_func = models.CharField(max_length=100)
    participa = models.ManyToManyField(Projeto, through='Membro')

    def __unicode__(self):
        return u'%s %s' %(self.nome_func, self.sobrenome_func)
       
class Membro(models.Model):
    proj_id=models.ForeignKey(Projeto)
    func_id=models.ForeignKey(Funcionario)


class Andamento(models.Model):
   
    tipo = models.CharField(max_length=30)
   
    def __unicode__(self):
        return u'%s' % self.tipo

class OS(models.Model):
    proj_id=models.ForeignKey(Projeto)
    adamento_id=models.ForeignKey(Andamento)
    participa = models.ManyToManyField(Funcionario, through='Desenvolve')
    num_os= models.CharField(max_length=50)
    data_ini = models.DateTimeField()
    data_fim = models.DateTimeField()
    desc_os = models.TextField()
   
    def __unicode__(self):
        return u'%s' % self.num_os
   
    def save(self):
        os_save=super(OS,self).save()
       
class Desenvolve(models.Model):
    os_id=models.ForeignKey(OS)
    func_id=models.ForeignKey(Funcionario)

3 comments

Gabriel Genellina 12 years, 3 months ago  # | flag

Is this related to recipe 576898? I still don't get what is this for - could you explain?

Hi Gabriel!

This is a model for folling Ordening Servirce, that OS have having register from other system. This code follow the entity relationship model and folling the model method from django. But sorry the code is writting in portugues. I put here, because i want to get the layout for my blog(www.tranqueira.net:8080/weblog)

We have one OS(Ording Service) and this OS have one project(Projeto), and one status(Andamento), this status and project you can register a name you want. That OS have a participation from many functionarys(Funcionario) and one or many functionary make(Desenvolve) one OS. One functionary participate (Membro) from one project(Projeto).

If think my english is not good for explain but if you dont understaing i can try better...

[]s

Marcello.

Gabriel Genellina 12 years, 2 months ago  # | flag

Ah, if the only intent was to obtain a colorful version of your Python code for posting in your blog, see recipe 52298 or pygments http://pygments.org/

I finally understood your original problem by reading the blog post.